Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 //Instantiates the BitVoicerSerial class BitVoicerSerial bvSerial = BitVoicerSerial(); //Stores the data type retrieved by getData() byte dataType = 0; //Stores the state of pin 4 byte pinVal = 0;

#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;x7){Steps=0;} if(Steps<0){Steps=7; } }

//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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft Visual Basic 2017 For Windows Web And Database Applications

Authors: Corinne Hoisington

1st Edition

1337102113, 978-1337102117

More Books

Students also viewed these Databases questions

Question

What is the Definition for Third Normal Form?

Answered: 1 week ago

Question

Provide two examples of a One-To-Many relationship.

Answered: 1 week ago