When I first got to the Spark, I had no clue on how to program anything. I probably still don’t, but I get by
Anyhow, it turned out I was right, and it wasn’t all that hard to edit the Tinker Firmware. Like you said, it was just “some lines of code”
if (pinNumber == 7){
digitalWrite(pinNumber, value);
delay(2000);
digitalWrite(pinNumber, LOW);
}
Turns out, that was all it took. If you set D7 high in the Tinker app, it will go HIGH, wait 2 seconds, and go LOW again. The only thing is that the text in the app doesn’t change accordingly. Luckily, there’s still an indicator; after the pin goes LOW again, it sends a return to the app, after which the background of the button on the app fades away. I know that sounds a bit vague, but you’ll see it once you try it.
To see how the Tinker app works, you can have a look at the relevant docs over here: http://docs.spark.io/tinker/#tinkering-with-tinker-the-tinker-firmware
or in the github as provides above by @ScruffR , although the docs do some more explaining
Either way, you can try out my code by pasting the code below in the web IDE/Spark DEV and flash it to your Core. After that, hit the button in the app, and watch in awe as you blink the tiny blue LED
int tinkerDigitalRead(String pin);
int tinkerDigitalWrite(String command);
int tinkerAnalogRead(String pin);
int tinkerAnalogWrite(String command);
//PUT YOUR VARIABLES HERE
void setup()
{
Spark.function("digitalread", tinkerDigitalRead);
Spark.function("digitalwrite", tinkerDigitalWrite);
Spark.function("analogread", tinkerAnalogRead);
Spark.function("analogwrite", tinkerAnalogWrite);
//PUT YOUR SETUP CODE HERE
}
void loop()
{
//PUT YOUR LOOP CODE HERE
}
int tinkerDigitalRead(String pin) {
int pinNumber = pin.charAt(1) - '0';
if (pinNumber< 0 || pinNumber >7) return -1;
if(pin.startsWith("D")) {
pinMode(pinNumber, INPUT_PULLDOWN);
return digitalRead(pinNumber);}
else if (pin.startsWith("A")){
pinMode(pinNumber+10, INPUT_PULLDOWN);
return digitalRead(pinNumber+10);}
return -2;
}
//D7,HIGH
int tinkerDigitalWrite(String command){
bool value = 0;
int pinNumber = command.charAt(1) - '0';
Serial.println(value);
Serial.println(pinNumber);
if (pinNumber< 0 || pinNumber >7)
return -1;
if(command.substring(3,7) == "HIGH")
value = 1;
else if(command.substring(3,6) == "LOW")
value = 0;
else
return -2;
if(command.startsWith("D")){
pinMode(pinNumber, OUTPUT);
//this checks if it's pin D7, then toggles
//it off after 2 seconds.
if (pinNumber == 7){
digitalWrite(pinNumber, value);
delay(2000);
digitalWrite(pinNumber, LOW);
}
else
//The above was the only thing that was added ^
digitalWrite(pinNumber, value);
return 1;
}
else if(command.startsWith("A")){
pinMode(pinNumber+10, OUTPUT);
digitalWrite(pinNumber+10, value);
return 1;
}
else
return -3;
}
int tinkerAnalogRead(String pin){
int pinNumber = pin.charAt(1) - '0';
if (pinNumber< 0 || pinNumber >7) return -1;
if(pin.startsWith("D")){
pinMode(pinNumber, INPUT);
return analogRead(pinNumber);}
else if (pin.startsWith("A")){
pinMode(pinNumber+10, INPUT);
return analogRead(pinNumber+10);}
return -2;
}
int tinkerAnalogWrite(String command){
int pinNumber = command.charAt(1) - '0';
if (pinNumber< 0 || pinNumber >7) return -1;
String value = command.substring(3);
if(command.startsWith("D")){
pinMode(pinNumber, OUTPUT);
analogWrite(pinNumber, value.toInt());
return 1;}
else if(command.startsWith("A")){
pinMode(pinNumber+10, OUTPUT);
analogWrite(pinNumber+10, value.toInt());
return 1;}
else return -2;
}