What's new
  • Welcome to PHCorner Forums. Take a moment to Sign up and gain unlimited access and extra privileges that guests are not entitled to, such as: All that and more! Registration is quick, simple and absolutely free. Join our community today!

C and C++ Tanong lang po sa arduino code

LifeIsShort

Eternal Poster
Established
Joined
Sep 12, 2016
Messages
1,324
Reaction score
299
Tanong lang kung anong statement ang gamitin for example magpili ako sa choices A, B, C. Tapos mag input si user kung anong gusto nya sa tatlo.

Sana may pumansin TY.
 

LifeIsShort

Eternal Poster
Tapos yung switch mo naka connect sa ground tapos dun sa pin#
justkeepcalm paps paki check ang code di ko kasi makuha ang gusto ko mangyari.
Bali four buttons lahat. ang flow dapat ng code ay after ko mag choose ng number then ang susunod ay pipindutin ko yung ika fourth button tapos kung ano yung napili ko na number ay yun ang dapat i perform.
612350
612351
 

LifeIsShort

Eternal Poster
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,20,4);
int setNum;
int P2=2;
int P3=3;
int P1=4;
int P4=5;
int LED=6;
int LED2=7;
int LED3=8;


void setup()
{
lcd.begin();
lcd.backlight();
lcd.clear();
pinMode(P2,INPUT_PULLUP);
pinMode(P3,INPUT_PULLUP);
pinMode(P1,INPUT_PULLUP);
pinMode(P4, INPUT_PULLUP);
pinMode(LED, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);
}

void loop() {
while(digitalRead(P1)==HIGH)
{
lcd.clear();
if(digitalRead(P2)==LOW)
{
if (setNum==3)
{
setNum=0;
}
else
{
setNum=setNum+1;
}
}
if(digitalRead(P3)==LOW)
{
if (setNum==0)
{
setNum=3;
}
else
{
setNum=setNum-1;
}
}
if (digitalRead(P4)==HIGH)
{
if (digitalRead((setNum,DEC))=='1')
{
digitalWrite(LED, HIGH);
delay(200);
digitalWrite(LED, LOW);
break;
}
else if (digitalRead((setNum,DEC))=='2')
{
digitalWrite(LED2, HIGH);
delay(200);
digitalWrite(LED2, LOW);
break;
}
else if (digitalRead((setNum,DEC))=='3')
{
digitalWrite(LED3, HIGH);
delay(200);
digitalWrite(LED3, LOW);
break;
}
}
lcd.setCursor(0,0);
lcd.print("Select Number :");
lcd.setCursor(17,0);
lcd.print(setNum,DEC);
lcd.setCursor(0,1);
lcd.print("1.RED LED");
lcd.setCursor(0,2);
lcd.print("2.BLUE LED");
lcd.setCursor(0,3);
lcd.print("3.GREEN LED");
delay(200);
}

delay(200);
}
 

pixkit

Addict
Is it difficult to format the code snippets with the code markers? It's hard to read the code snippets in free form.
 

justkeepcalm

Grasshopper
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,20,4);
int setNum;
int P2=2;
int P3=3;
int P1=4;
int P4=5;
int LED=6;
int LED2=7;
int LED3=8;


void setup()
{
lcd.begin();
lcd.backlight();
lcd.clear();
pinMode(P2,INPUT_PULLUP);
pinMode(P3,INPUT_PULLUP);
pinMode(P1,INPUT_PULLUP);
pinMode(P4, INPUT_PULLUP);
pinMode(LED, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);
}

void loop() {
while(digitalRead(P1)==HIGH)
{
lcd.clear();
if(digitalRead(P2)==LOW)
{
if (setNum==3)
{
setNum=0;
}
else
{
setNum=setNum+1;
}
}
if(digitalRead(P3)==LOW)
{
if (setNum==0)
{
setNum=3;
}
else
{
setNum=setNum-1;
}
}
if (digitalRead(P4)==HIGH)
{
if (digitalRead((setNum,DEC))=='1')
{
digitalWrite(LED, HIGH);
delay(200);
digitalWrite(LED, LOW);
break;
}
else if (digitalRead((setNum,DEC))=='2')
{
digitalWrite(LED2, HIGH);
delay(200);
digitalWrite(LED2, LOW);
break;
}
else if (digitalRead((setNum,DEC))=='3')
{
digitalWrite(LED3, HIGH);
delay(200);
digitalWrite(LED3, LOW);
break;
}
}
lcd.setCursor(0,0);
lcd.print("Select Number :");
lcd.setCursor(17,0);
lcd.print(setNum,DEC);
lcd.setCursor(0,1);
lcd.print("1.RED LED");
lcd.setCursor(0,2);
lcd.print("2.BLUE LED");
lcd.setCursor(0,3);
lcd.print("3.GREEN LED");
delay(200);
}

delay(200);
}
Anong issue na? Rather saan part ka na nal-lito?
 

LifeIsShort

Eternal Poster
Anong issue na? Rather saan part ka na nal-lito?
Walang nangyari after ko pinindot ang ika fourth button (P4). Walang umiilaw na LED. Bale ano ba dapat ang ilagay sa
() parenthesis para ma recognize nya yung ininput na choices dun sa commad line na
If (digitalRead() == ' ')
{
Statement;
break;
}
 

Trending Topics

Trending On This Forum

Unanswered Topics

Top