Professional Documents
Culture Documents
Task Task
1. Build up a 4-wheal vehicle
Build up a truss structure
- 4 modes: go, back, turn left and right
- a Bridge, a Vehicle Frame, a quadruped
2. Build up a quadruped machine
machine
- 5 modes: 4 modes upper + rotation
Hardware Control(1)
Outline
• Device Control (1,2)
• Driving Vehicle (1,2)
• Moving Machine (1,2)
• Motion of Vehicle and Machine by NFC (1,2)
• Simple Simulator (1,2,3)
• Motion of Human Walking (1,2)
• Using ADAMS(Analyzing Tool of Dynamics) (1,2,3)
Functions: I/O
• Digital I/O
digitalRead() / digitalWrite() / pinMode()
• Analog I/O
analogRead() / analogReference() /analogWrite()
https://www.arduino.cc/reference/en/
Digital I/O
EXAMPLE
- Sets pin 13 to the same value as pin 7, declared as an
• digitalRead() input
-Syntax
• digitalRead(pin)
• pin - the pin number for digital signal
• Returns: HIGH / LOW int ledPin = 13; // LED connected to digital pin 13
int inPin = 7; // pushbutton connected to digital pin 7
int val = 0; // variable to store the read value
• digitalWrite()
-Syntax void setup() {
pinMode(ledPin, OUTPUT); // sets the digital pin 13 as output
• digitalWrite(pin,value) :
pinMode(inPin, INPUT); // sets the digital pin 7 as input
• pin - the pin number for digital signal
}
• value – HIGH / LOW
void setup() {
Serial.begin(9600); // setup serial
}
void loop() {
val = analogRead(analogPin); // read the input pin
Serial.println(val); // debug value
}
Analog I/O PWM(Pulse Width Modulation)
- Description method of an analog value
• analogWrite()
-Syntax
• analogWrite(pin,value)
• Pin – the pin number for analog signal
• Value – 0~255
PWM map()
Task 3
• Control RGB LED by using three photo sensors
- input: 3 pin for photo sensors (analog)
- output: 3 pin for three LED (digital by PWM)
• Conditions
- Read the values coming through photo sensors
- Light on RGN LED following the signal values
Coding and Making
Recommendations
• Get your own devices
- Vehicle: Arduino Uno/Mega, 2 DC motors, 1 DC Motor Driv
er, 1 Servo motors, wifi module/Bluetooth module, External P
ower Kit
- Quadruped machine: Arduino Uno/Mega, 8 Servo motors, w
ifi module/Bluetooth module, External Power Kit
• For the next lecture
- Research about how to use DC motor and Servo motor
- Make a strategy for each moving mode
DC Motor driver
M Rotating speed
ot
or
Rotating
direction
M
ot
or
GND
+ External Power