Introduction: Visualize Your Bitcoin Gain and Loss With Arduino & Python
Personally I'm a crypto currency investor. But I also have a hevy load of work to attend to. So I am not able to keep tracking bitcoin price like 10 times a minute. However, I still want to know whether I'm earning or lossing money. Thus, I decided to build a real-time feedback system of my investment using python. And to visualize it, I chose a led strip and an arduino. If I earned money, the leds will turn green. If I lose, they will turn red.
How does it work
To get real-time bitcoin data, I used an api provided by OKex, which is a large crypto currency exchange. Then I used python to calculate my gain and loss based on the streaming data. I set my target gain and loss to 5% everyday, which means more lights are on, my investment is closer to my target gain or loss. If all leds are turned on or off, the strip will statr to blink. So I can make decision about whether to keep holding or sell my bitcoins.
Step 1: Connect Your Led Strip With Your Arduino Board
Connect your seeeduino with its base shield. Then plug in the led strip on digital pin 6 (D6)
Step 2: Connect Your Arduino Board to Your Computer
Check the port your arduino is using. You are going to need it in the python code.
Step 3: Upload the Arduino Code
Step 4: Run the Python Code
Make sure python library pyserial is installed. If you don't know whether you have installed the library, run
pip install pyserial
in your computer's terminal.
Befor executing the python code, remember to set up your initial investment data.
Step 5: Python Code
Step 6: Enjoy Your Real-time Bitcoin Investment Monitor!
Participated in the