Uses an Adafruit TCS34725 red/green/blue colour sensor to analyse the light output from the on-screen order book when crypto trading.
If predominantly "buy" orders come in, represented by green numbers on screen, you might possibly expect the value of your favourite coin to increase in the ultra-short term. If predominantly red "sell" orders start to fill the order book, then you might possibly expect the value of your coin to fall in the ultra-short term.
Therefore, here comes the innovative step, what would happen if you were to analyse the light output of just that section of your computer screen that is showing the order book, and then work out changes in the ratio of green light to red light over time?
This project uses an Adafruit TCS34725 red / green / blue light sensor attached to an Arduino Nano, fitted into a foil lined cardboard enclosure in turn mounted over the order book part of your cryptocurrency trading platform on screen view. It determines the mean red to green ratio over time and then alerts you with verbal warnings if the instantaneous red to green ratio measurement is moving away from this mean central area towards the red or green.
Any trading decisions you make based on this are entirely up to you! I have no idea if this is of value or not for trading but felt compelled to try it to see if it works as an idea. It does.
The verbal warning system does not require a speech synth module. The spoken alerts are generated by the same Arduino Nano using the "Talkie" library.
Main list of things you will need:
Arduino Nano 5V with the 328 processor
Adafruit TCS34725 colour sensor with IR filter and LED light
Some familiarity with Arduino boards and how to use them.
Small audio amplifier module LM386
8 Ohm 0.5 Watt speaker
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Which Part of the Screen Is the Order Book?
Using the Binance crypto trading market viewer, the list of buy and sell orders coming in are listed as a continuously changing flow of red and green numerical values in the column marked with the red box.
If we measure the proportion of red to green light emanating from this part of the screen, the hypothesis (unproven) is that this may give you a guide to short term sentiment, i.e. is everyone suddenly wanting to buy or sell?
Step 2: Mainly Red Versus Mainly Green
An example of the concept:
On the left is a screenshot of the order book for bitcoin which is mainly red at that point. A few minutes later it is mainly green.
Step 3: How Are We Going to Measure the Light From This Part of the Screen?
We will make a long thin foil lined cardboard structure which exactly fits over just this part of the screen.
Inside the box will be the TCS34725 sensor.
NOTE: As this sensor seems to read the light in a very small dot area in front of it, it is mounted facing AWAY from the screen inside the foil lined box as we do NOT want to measure the red/green ratio of a small dot on the laptop screen, we want to know the overall red/green ratio of this region of the screen. Therefore we let the light bounce around inside the foil lined enclosure and then the sensor measures the red/green ratio of this mixed up light. At least that was the intention.
Step 4: Cut Cardboard and Stick Foil to It.
Cut a shape like this based on the area of your own laptop the order book covers.
Screw up some aluminium foil, flatten it back out, and glue it to the cardboard with spray adhesive or similar. I scrunched up the foil as we want the light from this part of the screen to bounce around semi-randomly within the box.
Step 5: More Cardboard Fabrication
The cardboard part on the left has a rectangular slot made in it which is exactly the same shape as the area of the screen the order book is on.
The matching, now folded, foil lined box on the left will have the sensor fitted inside it and then will be taped over this hole with black electrical insulation tape so that light from the screen will enter through the rectangular hole and then bounce around inside the foil lined box.
Step 6: Mount the Colour Sensor
Here is a view of the cardboard structure we have made, from the side that will be laid over the computer screen.
As you can see I have usefully recycled the packaging from a well known brand of baked beans, the slimline variety for not-so-slimline people like me.
You can see that the colour sensor is mounted facing the uppermost roof of the box as we want it to read the average of all the light coming from that part of the computer screen, not just one small dot area of the laptop screen, which is what you would read if you pointed it directly at the computer screen.
Step 7: Solder Wires to Your Sensor
I tin my wires with solder and then use Blu-Tack as above to hold them in place through the holes while I solder them up. I find this much easier than using helping hand devices or similar. I also wear a pair of cheap x3 magnifying spectacles so I can see what I am doing.
Step 8: Wiring Colour Sensor to an Arduino Nano
I used an Arduino Nano but you could also use an Uno for this project. The nano is functionally similar but physically smaller.
You could now stop at this stage and run the software using the Arduino Serial View Window to see the outputs.
However I also added some talking alarms. This uses a voice synthesis library called Talkie which uses pulse width modulation on Digital Pin 3 of the Arduino to create speech from an attached speaker that sounds like a 1980's talking toy. However, it is practically free to implement as a user interface so I have started using this in some of my other projects too.
Step 9: Add a Little Audio Amplifier
If you wire a 0.5 Watt 8 Ohm speaker between digital Pin 3 of your Arduino Nano and ground, Talkie will produce some voice output through it OK. However, it will be very quiet. Therefore I also added a very low cost small audio amplifier. This connects to the Arduino with 3 wires and has 2 screw terminals to attach your speaker to. This makes the sound easier to hear.
Step 10: How to Wire Up the Small Audio Amplifier
3 wires between this module and the Arduino will do the job. The speaker suggested is 8 Ohm 0.5 Watt. These are found in many children's musical talking toys.
Step 11: The Whole Setup Assembled
Here you see the Arduino plugged into a USB port of the laptop. This powers it up. The ribbon cable then runs from the Arduino Nano / Amplifier Module / Speaker electronics resting on the top right of my keyboard, to the colour sensor inside the cardboard box. The foil lined cardboard enclosure is fixed over the order book part of my laptop screen using electrical tape. DO NOT APPLY TAPE TO YOUR COMPUTER SCREEN. I have used tape along top edge and right hand edge of the (plastic) screen frame.
Seal up any holes in your enclosure with black tape so daylight does not sneak into it. We only want light from the order book part of the computer screen to enter the cardboard enclosure, bounce around off the foil and then be read by the colour sensor.
Step 12: What About the "Talkie" Software Etc?
Talkie is an Arduino library which creates sound on Pin 3 of an Arduino. It uses code extracted from ROM chips of various old computers including some military aviation ones. It has a library of available words assembled from these various sources that you can use.
Therefore, although limited in the words you can use, it a) has a retro cool sound and b) costs practically nothing to add to your project.
For info on installing the Talkie library and an introduction to this, there is already a good instructable to so I urge you to read this link and follow the steps for installing the Talkie Arduino library onto your computer:
NOTE: You can omit this step if you want to and use the Arduino Serial View window to view the outputs from the program running on the Arduino Nano i.e. the one that is reading the light output, doing some maths on it and displaying the results every 2 seconds in the Serial View window.
Step 13: The Output Information
Here is a close up of my serial view window with the program running on the Arduino.
If you let it run for about 30 cycles, one cycle every 2 seconds at present, the mean value of the Red/Green ratio will have settled down to a steady value and the maximum and minimum values will have stabilised too.
The code then calculates a value mid-way between the mean and the minimum recorded value. If the measured value of RED divided by GREEN light intensity, at any time falls below this alarm limit, an alert will appear on screen that the proportion of green is rising relative to red i.e. there are mainly buy orders coming in, i.e. the value might possibly go up in ultra short term future.
If the measured red divided by green value starts to increase above an automatically set alarm point midway between the mean and the maximum measured value, then the amount of red to green light must be increasing, sell orders may be coming in and the value may go down in the ultra short term future.
NOTE: In trading terms this may all be nonsense, I have not run it for long enough to watch to see if it is of real-world use or not. It does however read a varying red/green ratio and it does give these alarms at the expected times.
Step 14: CODE Arduino Sketch
Here attached is the Arduino sketch I have used to make this all work as in the video on the front page.
It was cobbled together in a couple of hours so you may well be able to improve it.