Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int val;
- void setup() {
- Serial.begin(9600);
- //Setup Channel A
- pinMode(12, OUTPUT); //Initiates Motor Channel A pin
- pinMode(9, OUTPUT); //Initiates Brake Channel A pin
- pinMode(13, OUTPUT); //Initiates Motor Channel Bpin
- pinMode(8, OUTPUT); //Initiates Brake Channel A pin
- }
- void loop()
- {
- if (Serial.available()) { //[ch1077][ch1089][ch1083][ch1080] [ch1077][ch1089][ch1090][ch1100] [ch1087][ch1088][ch1080][ch1085][ch1103][ch1090][ch1099][ch1081] [ch1089][ch1080][ch1084][ch1074][ch1086][ch1083],
- val = Serial.read(); // [ch1090][ch1086] [ch1095][ch1080][ch1090][ch1072][ch1077][ch1084] [ch1077][ch1075][ch1086] [ch1080] [ch1089][ch1086][ch1093][ch1088][ch1072][ch1085][ch1103][ch1077][ch1084] [ch1074] val
- if (val == '8')
- {
- //forward @ full speed
- digitalWrite(12, HIGH); //Establishes forward direction of Channel A
- digitalWrite(9, LOW); //Disengage the Brake for Channel A
- analogWrite(3, 255); //Spins the motor on Channel A at full speed
- delay(250);
- }
- }
- if (val == '2')
- {
- digitalWrite(12, LOW); //Establishes backward direction of Channel A
- digitalWrite(9, LOW); //Disengage the Brake for Channel A
- analogWrite(3, 255); //Spins the motor on Channel A at half speed
- delay(250);
- }
- if (val == '5')
- {
- digitalWrite(12, HIGH); //Establishes backward direction of Channel A
- digitalWrite(9, HIGH); //Disengage the Brake for Channel A
- analogWrite(3, 255); //Spins the motor on Channel A at half speed
- digitalWrite(13, HIGH); //Establishes backward direction of Channel A
- digitalWrite(8, HIGH); //Disengage the Brake for Channel A
- analogWrite(11, 255); //Spins the motor on Channel A at half speed
- delay(250);
- }
- if (val == '4')
- {
- digitalWrite(13, HIGH); //Establishes backward direction of Channel A
- digitalWrite(8, LOW); //Disengage the Brake for Channel A
- analogWrite(11, 255); //Spins the motor on Channel A at half speed
- delay(250);
- }
- if (val == '6')
- {
- digitalWrite(13, LOW); //Establishes backward direction of Channel A
- digitalWrite(8, LOW); //Disengage the Brake for Channel A
- analogWrite(11, 255); //Spins the motor on Channel A at half speed
- delay(250);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement