I am doing a basic electronics course revolving around the Internet of Things*, and we have to make a final project to present what we have learnt.
* Hear me out - I don't think this belongs on IoT SE, since the question is electronics-based
My project involves lighting up an LED matrix with predefined input from the web.
There are three factors causing a problem for me:
- The LED matrix only seems to work on an Arduino (even though the programming language and setup are very similar), and we only have Arduino Unos available to us.
- We are required to use a Photon Redboard to receive/send data through the internet.
- The code running the LED matrix interferes with the TX/RX terminals on the Arduino since it uses the SPI bus, so after turning on the LED board I cannot receive any data from the Photon Redboard through the TX/RX pins (0 and 1).
Main question (to avoid the XY problem):
How could I receive digital data on the Arduino Uno from the Photon Redboard without using the serial ports?
What I have done to try to fix the problem:
- Google-fu didn't turn up anything.
- Changing the location of serial use in the programming - it works before the SPI bus is initialised but not after, which is useless for me since changing the board in response to an input from the Photon Redboard is the point of my project, and I can't change the board if it's not on.
- Connecting a digital port programmed for output on the Photon Redboard to a digital port programmed for input on the Arduino Uno — this gives a value on the Arduino Uno that seems to switch between HIGH and LOW every few seconds, regardless of how the Photon Redboard is programmed to send values.
If I am connecting the boards as described above, do I need to ground/insert current into the connection, and if so, is there a particular board this needs to be done on?
(Out of curiosity, also, what is causing the value to flip like this?)
- Checking the components individually - the LED matrix works fine by itself, serial over TX and RX works fine by itself, the digital pins work fine by themselves (NB: tests were carried out with an LED or a button to provide visual feedback).
Here are pictures of both the Photon Redboard and the Arduino Uno for reference (click on images for better resolution, Arduino just shows circuitry without chips etc.):
The code that seems to interfere with the Serial is below (directly copied from online here):
//----------SPI BUS SETUP---------- SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR1); //Enable SPI HW, Master Mode, divide clock by 16 //Set the pin modes for the RGB matrix pinMode(DATAOUT, OUTPUT); pinMode(DATAIN, INPUT); pinMode(SPICLOCK,OUTPUT); pinMode(SLAVESELECT,OUTPUT); //Make sure the RGB matrix is deactivated digitalWrite(SLAVESELECT,HIGH); //----------END SPI BUS SETUP----------
The four lines of
pinMode(PIN,I/O) refer to pins 10-13 (in standard SPI order, but I can't remember what order that is and I don't have access to the code).