hpr1691 :: Arduino 101 Arduino IO
In this episode, learn how to read and write input and output from the Arduino.
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:
- https://openclipart.org/detail/104167/breadboard-by-mesamike
- https://openclipart.org/detail/181334/microcontroller--by-b.gaultier-181334
And here are diagrams of the simple circuits that Klaatu constructs.
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.