Hello, I am a beginner, and I am controlling four leds from four pushbuttons on hardware side with arduino and on labview in UI I made four leds, is there anyway when I turn ON a specific LED on hardware side it will also turn ON in LABVIEW and I am also serial printing 1,2,3 or 4 when turning ON any specifc LED
below is the code of arduino and in attachment labview form is present:
byte led1 = 10;
byte led2 = 11;
byte led3 = 12;
byte led4 = 13;
byte but1 = 2;
int val1 = 0;
byte but2 = 3;
int val2 = 0;
byte but3 = 4;
int val3 = 0;
byte but4 = 5;
int val4 = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(led1,OUTPUT);
pinMode(led2,OUTPUT);
pinMode(led3,OUTPUT);
pinMode(led4,OUTPUT);
pinMode(but1,INPUT);
pinMode(but2,INPUT);
pinMode(but3,INPUT);
pinMode(but4,INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
val1 = digitalRead(but1);
val2 = digitalRead(but2);
val3 = digitalRead(but3);
val4 = digitalRead(but4);
if(val1 == LOW)
{
digitalWrite(led1,HIGH);
Serial.print(1);
}
else
digitalWrite(led1,LOW);
if(val2 == LOW)
{
digitalWrite(led2,HIGH);
Serial.print(2);
}
else
digitalWrite(led2,LOW);
if(val3 == LOW)
{
digitalWrite(led3,HIGH);
Serial.print(3);
}
else
digitalWrite(led3,LOW);
if(val4 == LOW)
{
digitalWrite(led4,HIGH);
Serial.print(4);
}
else
digitalWrite(led4,LOW);
}