set speed
This commit is contained in:
parent
60c6495fa3
commit
38430ac259
|
@ -79,16 +79,21 @@ void setup (void)
|
||||||
void loop (void)
|
void loop (void)
|
||||||
{
|
{
|
||||||
static int vbar = 0;
|
static int vbar = 0;
|
||||||
|
static int speed = 0;
|
||||||
int sensorValue1 = analogRead(A4);
|
int sensorValue1 = analogRead(A4);
|
||||||
int sensorValue2 = analogRead(A5);
|
int sensorValue2 = analogRead(A5);
|
||||||
|
|
||||||
vbar = sensorValue2/100;
|
vbar = (1023-sensorValue2)/100;
|
||||||
// Walk through the levels
|
if (vbar > 10){
|
||||||
bar.setLevel(10-vbar);
|
|
||||||
if (vbar >= 10){
|
|
||||||
vbar=0;
|
vbar=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("x: %d , y: %d \n",sensorValue1,sensorValue2);
|
bar.setLevel(vbar);
|
||||||
|
|
||||||
|
speed = (1023-sensorValue2) >> 2;
|
||||||
|
|
||||||
|
IN3_L; IN4_H; analogWrite(BB_Enable_B, speed);
|
||||||
|
|
||||||
|
printf("x: %d , y: %d bar: %d speed: %d\n",sensorValue1 ,sensorValue2, vbar, speed);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue