Question

In: Computer Science

Write a program that captures the transmission of a character from an Arduino board over serial...

Write a program that captures the transmission of a character from an Arduino board over serial communication (UART)

Solutions

Expert Solution

Answer : Given data

void setup()
{
// initialize the serial communication:
Serial.begin(9600);

// initialize the ledPin as an output:
  
pinMode(crankingPin, INPUT);
pinMode(liftoffPin, INPUT);
pinMode(upwardPin, INPUT);
pinMode(downwardPin, INPUT);
pinMode(turnleftPin, INPUT);
pinMode(turnrightPin, INPUT);
pinMode(forwardPin, INPUT);
pinMode(backwardPin, INPUT);
}

void loop()
{
if(digitalRead(offPin)==HIGH)
{
Serial.write('0');
delay(1000);
}
if(digitalRead(crankingPin)==HIGH)
{
Serial.write('1');
delay(1000);
}
if(digitalRead(liftoffPin)==HIGH)
{
Serial.write('2');
delay(1000);
}

if(digitalRead(upwardPin)==HIGH)
{
Serial.write('3');
delay(1000);
}

if(digitalRead(downwardPin)==HIGH)
{
Serial.write('4');
delay(1000);
}

if(digitalRead(turnleftPin)==HIGH)
{
Serial.write('5');
delay(1000);
}

if(digitalRead(turnrightPin)==HIGH)
{
Serial.write('6');
delay(1000);
}

if(digitalRead(forwardPin)==HIGH)
{
Serial.write('7');
delay(1000);
}
  
if(digitalRead(backwardPin)==HIGH)
{
Serial.write('8');
delay(1000);
}

}

_____________THE END__________________


Related Solutions

Write Arduino program to implement wiring three momentary switches to the Arduino board
Write Arduino program to implement wiring three momentary switches to the Arduino board
Write a program to run on your Arduino and PortMaster board that will sequentially turn on...
Write a program to run on your Arduino and PortMaster board that will sequentially turn on and off the LED segments, so it resembles Cylon eyes (https://youtu.be/UajcgzK2shQ). Use the millis() construct shown in lecture rather than delay(). The traverse from one side to the other should take about 1 second.
Write code in C language in the Arduino IDE ADC data using Serial plotter Serial plot...
Write code in C language in the Arduino IDE ADC data using Serial plotter Serial plot : raw data, delay data (int) Purpose: Delay Block (**Using Class**) Input : u(t) Output : o(t)=u(t-h) sample time=0.02 Delay (h) = 0.4
Write an LC-3 program that will repeatedly read a character from the keyboard. For each character...
Write an LC-3 program that will repeatedly read a character from the keyboard. For each character read in, your program will print a neat message that echoes the input value, and the ASCII character code of the input character in hexadecimal. It will run forever: no HALT or End of processing is required. For example: Please press a key: You pressed 'z' which is x7A Please press a key: You pressed '@' which is x40 Please press a key: You...
To begin, write a program to loop through a string character by character. If the character...
To begin, write a program to loop through a string character by character. If the character is a letter, print a question mark, otherwise print the character. Use the code below for the message string. This will be the first string that you will decode. Use the String class method .charAt(index) and the Character class method .isLetter(char). (You can cut and paste this line into your program.) String msg = "FIG PKWC OIE GJJCDVKLC MCVDFJEHIY BIDRHYO.\n"; String decryptKey = "QWERTYUIOPASDFGHJKLZXCVBNM";...
arduino c code only write a code that counts down a timer on serial monitor and...
arduino c code only write a code that counts down a timer on serial monitor and if A1 is typed into serial monitor prints the timer counting down and writes at 1 second hello and at 5 secs goodbye and repeats every 5 secs A2 is typed as above at 2 seconds writes hello and 3 seconds writes goodbye A3 same as above but at 3 seconds says hello and 2 seconds goodbye This continues until c is pressed to...
Write the following in C language for Arduino: Write a program that turns on the LED...
Write the following in C language for Arduino: Write a program that turns on the LED at 25%, 50%, 75%, 100%, and then 0% brightness with a one second delay in between each change. Remember you are going to need to use a PWM pin and use the "analogWrite" command. The maximum value for our Arduino R3 boards is 255 and you need five steps (25%, 50%, 75%, 100%, and 0%) so you will need to determine the values for...
Write a C++ program to read characters from the keyboard until a '#' character is read....
Write a C++ program to read characters from the keyboard until a '#' character is read. Then the program will find and print the number of uppercase letters read from the keyboard.
Write the following in C language for Arduino: Write a program that increases the LED brightness...
Write the following in C language for Arduino: Write a program that increases the LED brightness in five steps with each press of the button. Remember you are going to using a digital input and the "digitalRead" command. You are going to need to use a PWM pin and use the "analogWrite" command. The maximum value for our Arduino R3 boards is 255 and you need five steps (25%, 50%, 75%, 100%, and 0%) so you will need to determine...
Write a program that reads an integer, a list of words, and a character.
13.14 LAB: Contains the characterWrite a program that reads an integer, a list of words, and a character. The integer signifies how many words are in the list. The output of the program is every word in the list that contains the character at least once. Assume at least one word in the list will contain the given character.Ex: If the input is:4 hello zoo sleep drizzle zthen the output is:zoo drizzleIn c++ 
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT