dashboard simulator
in
Programming Questions
•
1 year ago
hi everybody,
I'm trying to make a car dashboard simulator with processing where I use 2 lines(1 for RPM and 1 for speed) as arrows. But when the line of the RPM gauge moves away from is start position the line of the speed gauge starts to move around the RPM line but when the RPM line is at the start position and I let the line of the speed gauge move then it moves normal. Does anyone have a solution for this. (the code is under the pictures)
- import processing.serial.*;
- import cc.arduino.*;
- Arduino arduino;
- PImage tacho, speedo;
- void setup()
- {
- size(900, 500);
- arduino = new Arduino(this, Arduino.list()[0], 57600);
- tacho = loadImage("tachometer.png");
- speedo = loadImage("speedometer.png");
- }
- void draw()
- {
- background(0);
- image(tacho, 90, 80);
- image(speedo, 500, 80);
- int valTacho = arduino.analogRead(0);
- int valSpeedo = arduino.analogRead(1);
- float tachoArrow = map(valTacho, 0, 1023, 240, -29);
- float speedoArrow = map(valSpeedo, 0, 1023, 250, -6);
- stroke(0, 255, 0);
- strokeWeight(4);
- translate(240,230);
- rotate(radians(tachoArrow));
- line(50, 0, -120, 0);
- translate(361,205);
- rotate(radians(speedoArrow));
- line(0, 0, -120 , 0);
- }
1