Arduino-Based Robotics
Arduino.cc
https://www.arduino.cc/
Arduino Create( Browser-Based)
https://create.arduino.cc/editor/
mBlock( Scratch-based Arduino)
http://learn.makeblock.com/en/software/
https://www.arduino.cc/
Arduino Create( Browser-Based)
https://create.arduino.cc/editor/
mBlock( Scratch-based Arduino)
http://learn.makeblock.com/en/software/
Introduction:
Super Awesome Sylvia
http://sylviashow.com/episodes/s1/e3/full/arduino
- Code: Strobe Light http://superawesomebook.com/strobe/
- Code: RIFF http://superawesomebook.com/RIFF/
Jody Culkin -Arduino Comic(pdf)
Introductory Arduino Class with Becky Stern( Instructables)
https://www.instructables.com/class/Arduino-Class/
This class will introduce you to the Arduino world. You'll learn the basics, build your first project, and so much more. Each lesson builds on your skills, infusing new knowledge and techniques along the way.
You'll start simple with exercises that demonstrate basic breadboard wiring and coding inputs and outputs. Then you'll level up to soldering and coding addressable NeoPixel LED strip and build an infinity mirror to show off your new fun hobby.
Start Arduino Kit (Technology Will Save Us)
https://www.techwillsaveus.com/resources/start-arduino-kit/
Start your journey into the wonderful world of programmable electronics. Learn to write your own code to make LEDs flash, speakers buzz and motors spin
https://www.instructables.com/class/Arduino-Class/
This class will introduce you to the Arduino world. You'll learn the basics, build your first project, and so much more. Each lesson builds on your skills, infusing new knowledge and techniques along the way.
You'll start simple with exercises that demonstrate basic breadboard wiring and coding inputs and outputs. Then you'll level up to soldering and coding addressable NeoPixel LED strip and build an infinity mirror to show off your new fun hobby.
Start Arduino Kit (Technology Will Save Us)
https://www.techwillsaveus.com/resources/start-arduino-kit/
Start your journey into the wonderful world of programmable electronics. Learn to write your own code to make LEDs flash, speakers buzz and motors spin
Adafruit- Arduino Tutorials by Simon Monk
- Lesson 4. Eight LEDs and a Shift Register
- Lesson 5. The Serial Monitor
- Lesson 6. Digital Inputs
- Lesson 7. Make an RGB LED Fader
- Lesson 8. Analog Inputs
- Lesson 9. Sensing Light
- Lesson 10. Making Sounds
- Lesson 11. LCD Displays - Part 1
- Lesson 12. LCD Displays - Part 2
- Lesson 13. DC Motors
- Lesson 14. Servo Motors
- Lesson 15. DC Motor Reversing
- Lesson 16. Stepper Motors
SIK Curriculum Guides
Pulse-Width Modulation
While the Arduino can only output high and low values, we can simulate an adjustable output by varying the duty cycle(on-time) of the output:
Projects:
- Simple Line Following Instructable
- Simple Light Following Robot
- Basic PD (Proportional-Derivative) Line Follower
Wiring Arduino Car:
1. Connect motors to motor screw terminals on L298 H- Bridge or on motor shield:
2. Connect Ground Wires( Black) from ground on Arduino to Ground on L298N, AND from Ground on Arduino to Ground Bus on Breadboard.
3. Connect Vin(orange) on Arduino to Vcc on L298N.
4. Connect 5V(red) on Arduino to 5V bus on breadboard,
5. Connect L298 to Arduino with 4-wire cable:
5V(Red) to 5V Bus on Breadboard
GND(Black) to GND bus on Breadboard
Trig(Gray) to Pin 2 on Arduino
Echo(Brown) to Pin 3 on Arduino
1. Connect motors to motor screw terminals on L298 H- Bridge or on motor shield:
2. Connect Ground Wires( Black) from ground on Arduino to Ground on L298N, AND from Ground on Arduino to Ground Bus on Breadboard.
3. Connect Vin(orange) on Arduino to Vcc on L298N.
4. Connect 5V(red) on Arduino to 5V bus on breadboard,
5. Connect L298 to Arduino with 4-wire cable:
- IN1(White) to Pin 9,
- IN2 (Green)to Pin 10,
- IN3(yellow) to Pin 11,
- IN4(blue) to Pin 12
5V(Red) to 5V Bus on Breadboard
GND(Black) to GND bus on Breadboard
Trig(Gray) to Pin 2 on Arduino
Echo(Brown) to Pin 3 on Arduino
Arduino Text Code-Starter Code
void setup() {
// set the pins you're using as outputs:
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
}
void loop() {
getDistance();
Serial.println (cm);
if ((cm<20) && (cm>1)){ // turn if object detected
turn() ;
delay(500);
}
else {
forward();
}
}
void forward() { //define going forwards function
digitalWrite(9, LOW); // set pin IN1 on L298 low
digitalWrite(10, HIGH); // set pin IN2 on L298 high
digitalWrite(11, LOW); // set pin IN3 on L293D low
digitalWrite(12, HIGH); // set pin IN4 on L293D high
}
void backward() { //define going backwards function
digitalWrite(9, HIGH); // set pin 2 on L293D high
digitalWrite(10, LOW); // set pin 7 on L293D low
digitalWrite(11, HIGH); // set pin 2 on L293D high
digitalWrite(12, LOW); // set pin 7 on L293D low
}
//this function measures distance
void getDistance() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite (trigPin, HIGH);
delayMicroseconds (10);
digitalWrite(trigPin, LOW);
duration= pulseIn(echoPin, HIGH);
cm= duration /29 /2;
delay(100);
}
void setup() {
// set the pins you're using as outputs:
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
}
void loop() {
getDistance();
Serial.println (cm);
if ((cm<20) && (cm>1)){ // turn if object detected
turn() ;
delay(500);
}
else {
forward();
}
}
void forward() { //define going forwards function
digitalWrite(9, LOW); // set pin IN1 on L298 low
digitalWrite(10, HIGH); // set pin IN2 on L298 high
digitalWrite(11, LOW); // set pin IN3 on L293D low
digitalWrite(12, HIGH); // set pin IN4 on L293D high
}
void backward() { //define going backwards function
digitalWrite(9, HIGH); // set pin 2 on L293D high
digitalWrite(10, LOW); // set pin 7 on L293D low
digitalWrite(11, HIGH); // set pin 2 on L293D high
digitalWrite(12, LOW); // set pin 7 on L293D low
}
//this function measures distance
void getDistance() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite (trigPin, HIGH);
delayMicroseconds (10);
digitalWrite(trigPin, LOW);
duration= pulseIn(echoPin, HIGH);
cm= duration /29 /2;
delay(100);
}
Arduino Code Using MBlock
In the following example, the motors are connected to a LM798N H-bridge.
pins 9&10 control the left motor, and pins 11&12 control the right motor
pins 9&10 control the left motor, and pins 11&12 control the right motor
Motors for a small robot can powered through the use of
Pins 3 and 11 control the speed using Pulse Width Modulation using a value between 0 and 255.
Pins 12 and 13 control direction of the motors by being either High or Low:
- the Arduino Motor Shield( https://www.arduino.cc/en/Main/ArduinoMotorShieldR3 )
Pins 3 and 11 control the speed using Pulse Width Modulation using a value between 0 and 255.
Pins 12 and 13 control direction of the motors by being either High or Low:
Bluetooth Remote Control
Starter Code- HC-05 Bluetooth Module/*
Bluetooth Sketch for HC-05 Bluetooth Module
HC-05 Wiring: Vcc to 3.3V on Arduino
GND to GND on Arduino
Tx to RX on Arduino
RX to TX on Arduino
HC-05 must be paired to computer using Preferences---Bluetooth; pairing code is 1234
Note: When uploading program to Arduino, HC-05 TX and Rx pins must be
temporarily disconnected.
When transmitting to HC-05, Select HC-05 as serial port on computer
*/
char junk;
String inputString = "";
void setup() // run once, when the sketch starts
{
Serial.begin(9600); // set the baud rate to 9600, same should be of your Serial Monitor
}
void loop()
{
if (Serial.available()) {
while (Serial.available())
{
char inChar = (char)Serial.read(); //read the input
inputString += inChar; //make a string of the characters coming on serial
}
Serial.println(inputString);
while (Serial.available() > 0)
{
junk = Serial.read() ; // clear the serial buffer
}
if (inputString == "a") { //in case of 'a' play note 1
tone(8, 440); // some function
} else if (inputString == "b") { //incase of 'b' play note 2
tone(8, 550);
} else if (inputString == "c") { //incase of 'b' play note 3
tone(8, 640);
}
else if (inputString == "d") { //incase of 'b' turn sound off
noTone(8);
} hjj /
inputString = "";
}
}
Bluetooth Sketch for HC-05 Bluetooth Module
HC-05 Wiring: Vcc to 3.3V on Arduino
GND to GND on Arduino
Tx to RX on Arduino
RX to TX on Arduino
HC-05 must be paired to computer using Preferences---Bluetooth; pairing code is 1234
Note: When uploading program to Arduino, HC-05 TX and Rx pins must be
temporarily disconnected.
When transmitting to HC-05, Select HC-05 as serial port on computer
*/
char junk;
String inputString = "";
void setup() // run once, when the sketch starts
{
Serial.begin(9600); // set the baud rate to 9600, same should be of your Serial Monitor
}
void loop()
{
if (Serial.available()) {
while (Serial.available())
{
char inChar = (char)Serial.read(); //read the input
inputString += inChar; //make a string of the characters coming on serial
}
Serial.println(inputString);
while (Serial.available() > 0)
{
junk = Serial.read() ; // clear the serial buffer
}
if (inputString == "a") { //in case of 'a' play note 1
tone(8, 440); // some function
} else if (inputString == "b") { //incase of 'b' play note 2
tone(8, 550);
} else if (inputString == "c") { //incase of 'b' play note 3
tone(8, 640);
}
else if (inputString == "d") { //incase of 'b' turn sound off
noTone(8);
} hjj /
inputString = "";
}
}