02-06-2021, 02:58 PM
Sve probao i nece.Na serial monitoru menja vrednosti kad se okrece potenciometar.
int taster1 = 2;
int taster2 = 3;
int ledpin1 = 7;
int ledpin2 = 8;
const int analog1 = A1;
const int analog2 = A2;
int ana1 = 0;
int ana2 = 0;
void setup() {
Serial.begin(115200);
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);
Serial.print ("radi");
Serial.println(ana1);
}
else
{
digitalWrite(ledpin1,LOW);
Serial.print ("**");
Serial.println(ana1);
}
if(digitalRead(taster2) == LOW)
{
ana2 = analogRead(analog2);
if(ana2 > 500)
analogWrite(ledpin2,HIGH);
Serial.print ("radi");
Serial.println(ana2);
}
else
{
digitalWrite(ledpin2,LOW);
Serial.print ("##");
Serial.println(ana2);
}
}
int taster1 = 2;
int taster2 = 3;
int ledpin1 = 7;
int ledpin2 = 8;
const int analog1 = A1;
const int analog2 = A2;
int ana1 = 0;
int ana2 = 0;
void setup() {
Serial.begin(115200);
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);
Serial.print ("radi");
Serial.println(ana1);
}
else
{
digitalWrite(ledpin1,LOW);
Serial.print ("**");
Serial.println(ana1);
}
if(digitalRead(taster2) == LOW)
{
ana2 = analogRead(analog2);
if(ana2 > 500)
analogWrite(ledpin2,HIGH);
Serial.print ("radi");
Serial.println(ana2);
}
else
{
digitalWrite(ledpin2,LOW);
Serial.print ("##");
Serial.println(ana2);
}
}