CEED Camp Instructor Reseources Blog
Tuesday, June 5, 2018
Toll Gate sample Arduino code
#include <Servo.h>
Servo JimServo;
void setup() {
// put your setup code here, to run once:
JimServo.attach(6); // My white wire is connected to Pin 6.
Serial.begin(9600);
}
char gate = 0;
void loop() {
// put your main code here, to run repeatedly:
if (Serial.available()>0) { // is a character other than 0 available?
gate=Serial.read();
}
if (gate=='d'){ // if a user has typed a d
Serial.println("\t Gate is down");
JimServo.write(0);
delay(2000);
}
if (gate=='u'){ // if a user has typed a u
Serial.println("\t Gate is now OPEN");
JimServo.write(180);
delay(2000);
}
}
Servo JimServo;
void setup() {
// put your setup code here, to run once:
JimServo.attach(6); // My white wire is connected to Pin 6.
Serial.begin(9600);
}
char gate = 0;
void loop() {
// put your main code here, to run repeatedly:
if (Serial.available()>0) { // is a character other than 0 available?
gate=Serial.read();
}
if (gate=='d'){ // if a user has typed a d
Serial.println("\t Gate is down");
JimServo.write(0);
delay(2000);
}
if (gate=='u'){ // if a user has typed a u
Serial.println("\t Gate is now OPEN");
JimServo.write(180);
delay(2000);
}
}
Arduino Kits for Consideration
Four options for your consideration.
The official Arduino kit:
This is the kit provided by Arduino, and it includes the very useful book. AMAZON LINK
Option 1. Minimalist programmer
This is a very inexpensive kit that uses an Uno that is built on the same schematic as the Arduino Uno. It is sold on Amazon by LANDZO and has the minimal basics for programming experiments. Unfortuantely it appears currently unavailable, but is often priced below $9. AMAZON LINK
Option 2. Beginning tinkerer and programmer
Similarly inexpensive is this Elegoo Uno kit, which comes with a small case, a tutorial CD, and a few additional items at just $17.99.
AMAZON LINK
Option 3. Super starter kit
The best value, however, is likely this Elegoo Uno kit with a much greater variety of sensors and actuators, for just $10 more:
AMAZON LINK
Option 4. The comprehensive starter kit
A similarly good value, this kit will keep even avid tinkerers busy for years of learning. It's about double the current price of Option 3, at $59.
AMAZON LINK
Welcome to our online resources!
The resources in this blog are available for any interested teacher. To learn more, contact me at JimE@vt.edu.
Subscribe to:
Posts (Atom)