Moving a Motor with a Browser

I have had success getting my daily step count from my FitBit to display on my motorized slide potentiometer, (circuit below) but then I ran into a problem: My FitBit was out of battery, and showed only “0” steps for the day. (I lost my charger– ugh! everything should be USB compatible without a stupid dongle charger!) 

Anyway, I realized that I needed another way to control my device for testing purposes and to demonstrate its function, so I don’t have to do jumping jacks throughout my thesis presentation to show it change.

SliderBreadboard_bb

I decided to create another webpage that could communicate with the slider as if it were the FitBit. I could run the server that looks for FitBit on my laptop, or I could run this new one for testing purposes and not need to change the code on my Arduino.

SliderSteps

On this page, moving the slider would set the same value as the FitBit (“steps”).

The trouble I had, and have been having, is understanding the difference between data types when sending data between code languages, across the internet, or from API’s. This is a really hard thing for me to grasp. In this case, I mashed up the “Express Basics” and “JS Client Thermostat” examples from Tom Igoe’s network examples. I discovered that after receiving the value of the slider (example “14” above) on the YUN, it was in Ascii.

So, I would need to convert the value to a string on the server:

Screen Shot 2014-04-21 at 8.12.31 AM

(My first try is still commented out)

And then convert it back into a number on the Arduino side:

Screen Shot 2014-04-21 at 8.14.17 AM

Ok, so this seems to be working! OMG so happy! Thanks to Tom for helping me understand what needed to be done.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s