I’m using all 16 GPIO as outputs in my current project, but would like to have at least one, preferably two input buttons.
I’m not using the RX,TX pins, but from what I’ve read on the forum I can’t change the use of these pins, is that correct ?
It would also appear that I can’t “mess” with the mode button.
So is my only option to multiplex some of the outputs in order to free up a couple of GPIO for switches ?
My project is currently using the 16 outputs at hopefully reliable millisecond accurate timings, is this likely to be effected by multiplexing outputs ?
I would like to add a button to start playback of a saved sequence and i’m also looking into maybe adding a button that could be used to control when the core connects to the cloud (i.e “push this button to connect, push and hold for 5 secs to disconnect”)
If it really comes to it then I guess I have to sacrifice 2 outputs to get these two buttons, but if there’s any other way I’d be happy to give it a go
Cheers,
mala
Thanks for posting the links peekay123.
I think I would like to try and use the 74HC595 shift register IC that I have in the maker kit rather than buying the MCP23017.
Although there don’t seem to be as many examples with this part, it may be a bit more difficult for me to learn.
@mala, great choice if you don’t need the fancy features! Look in Arduino land for lots of examples of using the 74HC595. There are some topics in this forum where the 74HC595 was used for driving parallel LCD displays as well.
Seems like a good choice, but then again all the examples for the Arduino appear to use a library and functions that are not immediately available on the SparkCore, so that’s gonna leave me scratching my head for a while!
No that's not correct , you can make TX and RX digital IO's if you haven't enabled the Serial1 peripheral. Just tested this:
#include "application.h"
bool s = false;
void setup() {
// Enable On-board blue LED
pinMode(D7,OUTPUT);
// Make TX and RX digital IO
// Physically jumper TX to RX (with a 1k ohm resistor at first,
// in case you mess up the code. Once you know it works,
// you can switch to just a wire)
pinMode(TX,OUTPUT);
pinMode(RX,INPUT);
}
void loop() {
// Toggle TX output, which feeds RX input
s = !s;
digitalWrite(TX,s);
// Update onboard D7 LED with state of RX input
digitalWrite(D7, digitalRead(RX) );
// Delay so we can see it change
delay(500);
}
@BDub thanks thats good to know…
Bit scared to try it just now, as I’ve had to do the first ever factory reset on my core…after it refusing to have anything flashed to it from the Web IDE
I wouldn’t worry too much about that… I’ve done factory resets a million times. So much so that to make it faster I put the Core in DFU mode and run a script that flashes the factory firmware just to speed it up a little. It’s a nice way to get back to a solid starting point for testing all kinds of stuff, like the OTA process or if you wrote some code that’s locking you out of OTA reprogramming.
Look at it as your safety net… don’t worry it’s there, go ahead and jump!
Have tried both your suggestions… using the TX/RX as GPIO seemed surprisingly simple.
The Shift register “hello world” example here http://arduino.cc/en/tutorial/ShiftOut
is very pretty !
I will experiment working them both into versions of my project
The shift register may eventually win (dependent on timing accuracy) as I’m thinking it could be handy to use the RX/TX to link multiple units together at some point.