Question
can you guys fix this the following code... it is an Arduino code. just put the terms and syntax in order //Imports the BitVoicer library
can you guys fix this the following code... it is an Arduino code. just put the terms and syntax in order
//Imports the BitVoicer library to the sketch #include
#define IN1 8 #define IN2 9 #define IN3 10 #define IN4 11 int Steps = 0; boolean Direction = true;// gre unsigned long last_time; unsigned long currentMillis ; int steps_left=4095; long time;
void setup() { //Starts serial communication at 9600 bps Serial.begin(9600); pinMode(IN1, OUTPUT); pinMode(IN2, OUTPUT); pinMode(IN3, OUTPUT); pinMode(IN4, OUTPUT); //Sets digital pin 4 as OUTPUT pinMode(4, OUTPUT); //Turns off pin 4 digitalWrite(4, pinVal); } void loop() { // read bitvoicer stuff
while(steps_left>0){ currentMillis = micros(); if(currentMillis-last_time>=1000){ stepper(1); time=time+micros()-last_time; last_time=micros(); steps_left--; } } Serial.println(time); Serial.println("Wait...!"); delay(2000); Direction=!Direction; steps_left=4095; }
void stepper(int xw){ for (int x=0;x
//This function runs every time serial data is available //in the serial buffer after a loop void serialEvent() { //Reads the serial buffer and stores the received data type dataType = bvSerial.getData();
//Checks if the data type is the same as the one in the //Voice Schema if (dataType == BV_BYTE) { //Checks the stored value in byteData by getData() and //changes the value of the pin if (bvSerial.byteData == 0) pinVal = LOW; else pinVal = HIGH; } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started