Thanks for attending the Arduino class!
You might be wondering what the little circuit board your child brought home is and what it's good for. The board is called an Arduino and it's a programmable microcontroller, which is just a fancy way of saying it's a little computer.
During class we all programmed them together to take a reading from a light sensor and activate a servo motor if a threshold was reached. In practice, this made for a super simple motion detector to make a head turn or a pumpkin move if it 'sensed' a shadow. The code is written in an Arduino variant of C++ that we uploaded using the Arduino IDE. The entirety of it is as follows:
#include <Servo.h>
Servo myservo;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(13, OUTPUT);
myservo.attach(9);
}
void loop() {
// put your main code here, to run repeatedly:
int reading = analogRead(A0);
Serial.println(reading);
delay(100);
if(reading < 800) {
digitalWrite(13, HIGH);
myservo.write(0);
} else {
digitalWrite(13, LOW);
myservo.write(60);
}
}
The circuit, which is put together on the breadboard with jumper wires, looks like this:
Any wire will do, and which color you use doesn't really matter, they all conduct electricity the same.
I encourage you to download the free IDE linked below and try to recreate the circuit, or extend it! A great place to get started is go to File -> Examples -> Basics -> Blink
which can run on the hardware with no additional circuitry. Plug in the Arduino to a computer with the USB cable and press Upload
and watch the built-in LED!
There are a plethora of projects around the Internet that use Arduino at their core, everything from weather stations to mobile robots to weather balloon payloads. Look around and don't hesitate to reach out if you have any questions.
- The Arduino IDE (it's free!)
- Fritzing (used for the circuit)
--
David Stillman
[email protected]