Moving a Gauge Needle by rotating it to a Position to set a Temperature

574 views
Skip to first unread message

billybbob18

unread,
Dec 1, 2016, 1:44:50 AM12/1/16
to MIT App Inventor Forum
Hello, Im having issues trying to scour the webs for an example of how to move a gauge needle sprite to a position within a circular stationary backround sprite. I already know how to tap it into position, but I want the action to FOLLOW the finger movement across the canvass. Any help / examples, AIA links, redirects would be appreciated. I don't need any help mapping the angle to a value as my math is strong, but sliding the needle around seems to be my biggest headache.

Thank You!

 
gauge image sprite.png

billybbob18

unread,
Dec 1, 2016, 1:46:02 AM12/1/16
to MIT App Inventor Forum
BTW, I'm using Android APP Inventor 2

billybbob18

unread,
Dec 1, 2016, 3:32:25 AM12/1/16
to mitappinv...@googlegroups.com
NEVER MIND!
 I FIGURED IT OUT! 

Here's the AIA, APK, All relevant image sprites. That should be all you need to get the idea. There's a part where I add 17 to the lowest number I wish to send over bluetooth, because it was negative 17. You cant handle neg numbers on the buletooth serial com on an arduino. Theres another part where I make comparisons so that if I drag the needle outside of my desired range, it will fall to the min or max value (whichever is closer) on the arduino side, I had to flip the readings around and map them to my desired value range. Arduino code looks like this. I do this for a living, so i appreciate donations, but I'm glad to hand this out to the needy as a freebie. If you wish to donate, then send me an email with (I have a donation for you)  in the subject line. And I'll send you a paypal donate request ENJOY!



#include <softwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX for the HC-06 Bluetooth module TX of one goes to the RX of the other and vice versa

void setup(){

Serial.begin(9600);
mySerial.begin(9600);
}

void loop(){

  if(mySerial.available > 0){
    byte newVal = (mySerial.read());
  }
  
   newVal = map (newVal, 160, 0, 75, 180);    // you'll get a declining number as you move the needle to the right, so the mapping needs to be done in reverse.
   Serial.println(newVal);

}
Blank Gauge with numbers F.png
StepperMotorPointer.png
GaugeExample (1).aia

Taifun

unread,
Dec 1, 2016, 8:41:20 AM12/1/16
to MIT App Inventor Forum
you might want to add a screenshot of the relevant blocks and your aia file into this thread
this could help others, who are looking for a solution to a similar problem

Taifun

Trying to push the limits of App Inventor! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun. 

billybbob18

unread,
Dec 1, 2016, 10:12:44 AM12/1/16
to MIT App Inventor Forum
I updated my previous comment. Enjoy.
Reply all
Reply to author
Forward
0 new messages