In C Language Please Your program reads in a String that a user types in at the
ID: 3600247 • Letter: I
Question
In C Language Please
Your program reads in a String that a user types in at the keyboard, parses it into the items of this structure, initializes a structure on this data, and prints the structure back out to the user formatted cleanly.
Q4) Create an Arduino program that uses enum to create 3 states and does the following in
the states respectively:
· State 1 - Starts a DC motor moving forward (this action should not stop)
· State 2 - Waits for either your IR or Ultrasonic sensor to register an object within 10 centimeters.
· State 3 - Turns the DC motor backwards for 1 second.
The program should run through the states in a repeating loop.
Explanation / Answer
dafruit Arduino - Lesson 15. Bi-directional Motor */ int enablePin = 11; int in1Pin = 10; int in2Pin = 9; int switchPin = 7; int potPin = 0; void setup() { pinMode(in1Pin, OUTPUT); pinMode(in2Pin, OUTPUT); pinMode(enablePin, OUTPUT); pinMode(switchPin, INPUT_PULLUP); } void loop() { int speed = analogRead(potPin) / 4; boolean reverse = digitalRead(switchPin); setMotor(speed, reverse); } void setMotor(int speed, boolean reverse) { analogWrite(enablePin, speed); digitalWrite(in1Pin, ! reverse); digitalWrite(in2Pin, reverse); }