Hi, im fairly new to this and i have a question that is probably an easy fix
instead of trying yo explain able show code , tell problem...
this code have want output the value when value has been changed problem i'm having getting starting value not reset every second when loops resets resets value not got value compare against see weather has changed.
the output i'm getting this...
time: 6820ms
time: 00ms
time: 6830ms
time: 00ms
time: 6820ms
time: 00ms
time: 6820ms
time: 00ms
time: 6820ms
time: 00ms
thanks
code: [select]
int adc0 = 0;
int value;
int newvalue;
int ledpin = 13;
void setup() {
serial.begin(9600);
pinmode(ledpin, 1);
value = analogread(adc0);
}
void loop() {
newvalue = analogread(adc0);
if(value == newvalue){
digitalwrite(ledpin, 1);
}else{
digitalwrite(ledpin, 0);
value = newvalue;
serial.print("time: ");
string values = string(value);
string timer = string(values + "0ms");
serial.println(timer);
}
delay(1000);
}
this code have want output the value when value has been changed problem i'm having getting starting value not reset every second when loops resets resets value not got value compare against see weather has changed.
the output i'm getting this...
time: 6820ms
time: 00ms
time: 6830ms
time: 00ms
time: 6820ms
time: 00ms
time: 6820ms
time: 00ms
time: 6820ms
time: 00ms
thanks
hi jackt96
you measuring analog voltage on pin a0. have connected pin?
regards
ray
code: [select]
int adc0 = 0;
...
value = analogread(adc0);
you measuring analog voltage on pin a0. have connected pin?
regards
ray
Arduino Forum > Using Arduino > Programming Questions > Hi, im fairly new to this and i have a question that is probably an easy fix
arduino
Comments
Post a Comment