Hey everyone,
So I am super excited that my spark core came in the mail. I already had a project in mind that I wanted to implement: a wi-fi door lock/unlock. I made some assumptions that turned out to be incorrect:
I assumed that the Tinker app was the direct interface to the core (which it technically is), but not strictly for prototyping.
I assumed that you could write some code, upload it to the Spark core, and then still control the pins using the Tinker app in conjunction with the code that was loaded on to the core.
So, as I have come to learn, this is not how the Spark core works. I wanted to be able to trigger a servo, one that is connected to a basic sliding door lock, to be either in a lock or unlock position based on a high or low pin signal. I thought that I could control this pin signal using the Tinker app, with my servoLock code already loaded on to it.
My question is, how do you send signals to the spark core over wifi if you can’t use the Tinker app?
Here is my code if you want to see what I was trying to do:
#define LOCKPIN 6
#define KEYPIN 7
Servo doorLock;
const int locked = 180;
const int unlocked = 0;
bool unlockDoor = false;
void checkKeyStatus();
void doorHandle(bool unlockDoor);
void setup() {
doorLock.attach(A7);
pinMode(LOCKPIN, INPUT);
pinMode(KEYPIN, OUTPUT);
}
void loop() {
checkKeyStatus();
doorHandle(unlockDoor);
delay(500);
}
void checkKeyStatus(){
int key = digitalRead(KEYPIN);
if (key){
unlockDoor = true;
}
else {
unlockDoor = false;
}
}
void doorHandle(bool unlockDoor){
if (unlockDoor){
doorLock.write(unlocked);
}
else {
doorLock.write(locked);
}
}
KEYPIN is the pin that I wanted to set high or low using Tinker, and LOCKPIN was the pin that was going to read the value on KEYPIN by shorting the two.
Thanks for your help/input!