- Driving Motors and Other Output Devices
- Demonstrate microcontroller controlling signal lamp
void setup() {
pinMode(9, OUTPUT); //Initialize Digital Pin 9 as an output
}
void loop() {
digitalWrite(9, HIGH); // turn the LED on (HIGH is the voltage level)
delay(5000); // wait for a second
digitalWrite(9, LOW); // turn the LED off by making the voltage LOW
delay(3000); // wait for a second
}
2. Demonstrate Darlington controlling signal lamp
3. Demonstrate microcontroller controlling motor
void setup() {
pinMode(9, OUTPUT); //Initialize Digital Pin 9 as an output
}
void loop() {
digitalWrite(9, HIGH); // turn the motor on (HIGH is the voltage level)
delay(5000); // wait for a second
digitalWrite(9, LOW); // turn the motor off by making the voltage LOW
delay(3000); // wait for a second
}
4. Demonstrate PWM signal driving motor
#define motorPin 9 //Motor connected to dig. pin 9
void setup() {
// nothing happens in set up
}
void loop() {
analogWrite (motorPin, 90);//set motor to 20%
delay (1000);
analogWrite (motorPin, 50);//set motor to 90%
delay (1000);
}
- Bi-directional Motor Control
- This first video demonstrates DPDT relay controlled the motor in both directions.
- In addition, this next picture and video shows a motor being controlled in opposing directions because of the arduino programming.
Here is the code for this achievement
void setup() {pinMode (13, OUTPUT) ; //Initialize Digital Pin 13 as an outputpinMode (12, OUTPUT) ; //Initialize Digital Pin 12 as an output}void loop () {digitalWrite (13,HIGH) ; //Set the motor On ClockWisedelay (100); //Wait for 1000 ms (1 Second)digitalWrite(13,LOW); //Set the LED offdelay (1000); //Wait for 1 seconddigitalWrite (12,HIGH) ; //Set the motor On CounterClockWisedelay (100); //Wait for 1000 ms (1 Second)digitalWrite(12,LOW); //Set the LED offdelay (1000); //Wait for 1 second}
No comments:
Post a Comment