Im currently building a cooler that has a lid and lock that automatically opens with someone checks in on Foursquare. While Im building it Im using temporary code that can be controlled through the serial monitor so that I can get the timing and range of motion down. My problem is that I cannot get both "servos" to work at the same time. The linear actuator will open/close the lid but the servo never activates. Here is the code Im working with, Im sorry ahead of time for any rookie mistakes that Ive made.
#include <Servo.h>
Servo servo; // Linear actuator opening lid
Servo servo2; // Servo controlling front lock
int val; // Value read from the serial port
void setup()
{
servo.attach(9); // Connect linear actuator
servo2.attach(10); // Connect front servo
Serial.begin(9600);
Serial.flush();
}
void loop()
{
// Read from serial port
if (Serial.available())
{
val = Serial.read();
Serial.print(val);
if (val == 110) // n = 110 in dec N = OPEN
{
{
servo.write(0);
servo2.write(180);
delay(25);
}
}
}
else if (val == 109) //109 = m in dec M = CLOSED
{
{
servo2.write(0);
servo.write(180);
delay(25);
}
}
}