Site Map - skip to main content

Hacker Public Radio

Your ideas, projects, opinions - podcasted.

New episodes every weekday Monday through Friday.
This page was generated by The HPR Robot at


hpr1691 :: Arduino 101 Arduino IO

In this episode, learn how to read and write input and output from the Arduino.

<< First, < Previous, , Latest >>

Hosted by Klaatu on Monday, 2015-01-26 is flagged as Clean and is released under a CC-BY-SA license.
Arduino, Arduino 101. 2.
The show is available on the Internet Archive at: https://archive.org/details/hpr1691

Listen in ogg, spx, or mp3 format. Play now:

Duration: 00:43:03

Arduino and related devices.

In this series various contributors talk about how to use and program Arduino single-board microcontrollers and related devices.
See the Wikipedia article https://en.wikipedia.org/wiki/List_of_Arduino_boards_and_compatible_systems for details of the range of devices.

In this two-part series, Klaatu introduces you to the Arduino. First, learn about the breadboard and how to make electricity course through it in order to power your very own simple circuit.

To follow along with what Klaatu is talking about, refer to these two graphics:

And here are diagrams of the simple circuits that Klaatu constructs.

image: a diagramme of the simple circuit in todays show

The simple code to reset the servo:

#include <Servo.h>
Servo myservo;

int servoPosition;

void setup()
{
  myservo.attach(13);
  myservo.write(90);
}

void loop() {}

And the code that responds to input:

#include <Servo.h>
Servo myservo; 

int servoPosition;
int servoMax = 180;
int servoMin = 0;

int value;
int valMax = 600;
int valMin = 50;


void setup()
{
  myservo.attach(13);
}

void loop() 
{
  value = analogRead(0);
  servoPosition = map(value, valMin, valMax, servoMax, servoMin);
  servoPosition = constrain(servoPosition, servoMin, servoMax);
  myservo.write(servoPosition);
}

And here is a bonus diagramme that you can try to create, using a light sensor, servo, and resistor.

image: homework

Comments

Subscribe to the comments RSS feed.

Comment #1 posted on 2015-01-27 22:09:32 by mcnalu

Arduislack

Really enjoying this Klaatu. Very timely as I'm getting my 10-year-old son into playing with his arduino and breadboard. Not only that, but we're using Slackware! So I'm picking up lots of useful tips from this series.

Comment #2 posted on 2015-01-29 18:47:35 by archer72

Very enjoyable show. I would consider getting an arduino if I can find a use case for it. Looking forward to the next show.

Leave Comment

Note to Verbose Commenters
If you can't fit everything you want to say in the comment below then you really should record a response show instead.

Note to Spammers
All comments are moderated. All links are checked by humans. We strip out all html. Feel free to record a show about yourself, or your industry, or any other topic we may find interesting. We also check shows for spam :).

Provide feedback
Your Name/Handle:
Title:
Comment:
Anti Spam Question: What does the letter P in HPR stand for?
Are you a spammer?
Who is the host of this show?
What does HPR mean to you?