Site Map - skip to main content - dyslexic font - mobile - text - print

Hacker Public Radio

Your ideas, projects, opinions - podcasted.

New episodes Monday through Friday.


From Wed 20th December 2017 all the media from the HPR feeds will be served via a redirect towards Archive.org. Please notify admin@HPR of any issues.

Our hosting is kindly provided by Josh from AnHonestHost.com. We would appreciate it if you could donate to help reduce his costs in funding the hosting.
He is also accepting bitcoins to 1KsxJr9HtsdaUeU7yaV9bk9bQi21UPBtUq

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 2015-01-26 is flagged as Clean and is released under a CC-BY-SA license.
Listen in ogg, spx, or mp3 format. | Comments (2)

Part of the series: 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-27T22:09:32Z 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-29T18:47:35Z 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 P in HPR stand for ?
Are you a spammer →
Who hosted this show →
What does HPR mean to you ?