Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Arduino - tutorijali, pitanja, primjeri i projekti
Jeste,greska u kucanju,sad se upali dioda koja treba kad se pritisne taster ali nereaguje na potenciometar,trebalo bi da se dioda pali i gasi prilikom okretanja potenciometa a ona je uvek upaljena.

const byte taster1 = 2;
const byte taster2 = 4;

const byte ledpin1 = 7;
const byte ledpin2 = 10;

const byte analog1 = A1;
const byte analog2 = A2;
int ana1 = 0;
int ana2 = 0;


void setup() {
pinMode(taster1,INPUT);
pinMode(taster2,INPUT);

pinMode(ledpin1,OUTPUT);
pinMode(ledpin2,OUTPUT);

pinMode(analog1, INPUT);
pinMode(analog2,INPUT);

digitalWrite(ledpin1,LOW);
digitalWrite(ledpin2,LOW);
}

void loop() {

if(digitalRead(taster1) == LOW)
{

ana1 = analogRead(analog1);
if(ana1 > 500)
digitalWrite(ledpin1,HIGH);
}
else
{
digitalWrite(ledpin1,LOW);
}

if(digitalRead(taster2) == LOW)
{
ana2 = analogRead(analog2);
if(ana2 > 100)
digitalWrite(ledpin2,HIGH);
}
else
{
digitalWrite(ledpin2,LOW);
}
}
Reply


Messages In This Thread
RE: Arduino - tutorijali, pitanja, primjeri i projekti - by MILANNN - 02-05-2021, 11:34 PM

Forum Jump:


Users browsing this thread: 39 Guest(s)