1

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.
Subquestion(s):

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.):

Photon Redboard Arduino Uno Sources: Sparkfun and Arduino main websites


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).

  • A quick google search says the photon board has an spi port. So, send the LED commands directly from the photon board to the LED controller and leave out the Arduino. – JRE Nov 2 '17 at 8:41
  • @JRE I tried that, but the code I acquired for the board used Arduino-specific variables that I couldn't work out how to transfer to the Photon board. Though they both have SPI capabilities, they are handled differently. – boboquack Nov 2 '17 at 8:43
  • Then start from the datasheet of the LED module and write your own code for the photon board. – JRE Nov 2 '17 at 11:32
  • The code running the LED matrix interferes with the TX/RX terminals on the Arduino since it uses the SPI bus - the TX/RX pins are not used for SPI. – Nick Gammon Nov 2 '17 at 20:44
  • @NickGammon I know, but presumably some internal variables are shared between Serial and SPI – boboquack Nov 2 '17 at 21:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.