set speed

This commit is contained in:
Harald Pichler 2017-07-20 16:26:38 +02:00
parent 60c6495fa3
commit 38430ac259

View file

@ -79,16 +79,21 @@ void setup (void)
void loop (void)
{
static int vbar = 0;
static int speed = 0;
int sensorValue1 = analogRead(A4);
int sensorValue2 = analogRead(A5);
vbar = sensorValue2/100;
// Walk through the levels
bar.setLevel(10-vbar);
if (vbar >= 10){
vbar = (1023-sensorValue2)/100;
if (vbar > 10){
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);
}