Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Translate the following code from arduino to MSP430 in C in order to control LEDs on a breadboard. // Arduino pins used for the LEDs
Translate the following code from arduino to MSP430 in C in order to control LEDs on a breadboard.
// Arduino pins used for the LEDs #define LED1 13 #define LED2 12 #define LED3 11 #define LED4 10 #define LED5 9 #define LED6 8 // Arduino pins used for the switches #define S1 7 #define S2 6 #define S3 5 #define S4 4 #define S5 3 #define S6 2 // State of each switch (0 or 1) int s1state; int s2state; int s3state; int s4state; int s5state; int s6state; void setup() { // pins for LEDs are outputs pinMode(LED1, OUTPUT); pinMode(LED2, OUTPUT); pinMode(LED3, OUTPUT); pinMode(LED4, OUTPUT); pinMode(LED5, OUTPUT); pinMode(LED6, OUTPUT); // pins for switches are inputs pinMode(S1, INPUT); pinMode(S2, INPUT); pinMode(S3, INPUT); pinMode(S4, INPUT); pinMode(S5, INPUT); pinMode(S6, INPUT); // setup serial port Serial.begin(9600); Serial.println("Serial port open"); } void loop() { s1state = digitalRead(S1); digitalWrite(LED1, s1state); s2state = digitalRead(S2); digitalWrite(LED2, s2state); s3state = digitalRead(S3); digitalWrite(LED3, s3state); s4state = digitalRead(S4); digitalWrite(LED4, s4state); s5state = digitalRead(S5); digitalWrite(LED5, s5state); s6state = digitalRead(S6); digitalWrite(LED6, s6state); Serial.print(s1state); Serial.print(s2state); Serial.print(s3state); Serial.print(s4state); Serial.print(s5state); Serial.print(s6state); Serial.println(); }
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