From 38430ac25996ff76fc27dc2e757b4fdc20a1d4d7 Mon Sep 17 00:00:00 2001 From: Harald Pichler Date: Thu, 20 Jul 2017 16:26:38 +0200 Subject: [PATCH] set speed --- examples/osd/lgb-train/sketch.pde | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/examples/osd/lgb-train/sketch.pde b/examples/osd/lgb-train/sketch.pde index 63ea6db82..8c52f8241 100644 --- a/examples/osd/lgb-train/sketch.pde +++ b/examples/osd/lgb-train/sketch.pde @@ -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; } + + bar.setLevel(vbar); - printf("x: %d , y: %d \n",sensorValue1,sensorValue2); + 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); }