Ah I see there’s code for smartie, I found it. I managed to implement the servo code and lcd example code
// include the library code:
#include <LiquidCrystal.h>
#include <Wire.h>
#include <VarSpeedServo.h> //variable speed servo library
#define REDLITE 3
#define GREENLITE 5
#define BLUELITE 6
//declare the constants to be used
#define LEDPIN 13 //pin attached to led
#define servoPIN 4 //Servo control line (orange) on Trinket Pin #2
#define SWitchPIN 2 //input from N.O. momentary switch
#define posOpenCMD 2400 //Define Clockwise Servo Limit in usec
#define posCloseCMD 600 //Define CounterClockwise Servo Limit in usec
#define DBdelay 200 //Duration of each button press in ms
#define MAXcnt 3 //Count of Button Presses needed for action
#define fastSPD 100 //speed setting; 1 = slowest, 255 is fastest
#define slowSPD 30 //Speed Servo/Door opens and closes
//declare the variables used
boolean wait = true; //wait for motion to complete, or don't
boolean doorOPEN = false; //desired door state set to closed
boolean SWstate = true; //state of switch, open = TRUE = not pushed
byte SWcnt = 0; //counter of same consecutive switch readings w/button = pressed
VarSpeedServo myServo; //create a servo object
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
// you can change the overall brightness by range 0 -> 255
int brightness = 255;
void setup() {
// set up the LCD's number of rows and columns:
lcd.begin(20, 4);
// Print a message to the LCD.
lcd.print("RGB 2x2 Display ");
lcd.setCursor(0,1);
lcd.print(" Multicolor LCD ");
pinMode(REDLITE, OUTPUT);
pinMode(GREENLITE, OUTPUT);
pinMode(BLUELITE, OUTPUT);
brightness = 100;
//set the pins to be ins or outs
pinMode(LEDPIN, OUTPUT);
digitalWrite(LEDPIN, LOW); //turn LED off
pinMode(servoPIN, OUTPUT);
pinMode(SWitchPIN, INPUT_PULLUP);
//CMD the servo to close the door
myServo.attach(servoPIN); // Attach the servo
myServo.slowmove(posCloseCMD, fastSPD); // Tell servo to go to closed position
}
void loop() {
for (int i = 0; i < 255; i++) {
setBacklight(i, 0, 255-i);
delay(5);
}
for (int i = 0; i < 255; i++) {
setBacklight(255-i, i, 0);
delay(5);
}
for (int i = 0; i < 255; i++) {
setBacklight(0, 255-i, i);
delay(5);
}
}
void setBacklight(uint8_t r, uint8_t g, uint8_t b) {
// normalize the red LED - its brighter than the rest!
r = map(r, 0, 255, 0, 100);
g = map(g, 0, 255, 0, 150);
r = map(r, 0, 255, 0, brightness);
g = map(g, 0, 255, 0, brightness);
b = map(b, 0, 255, 0, brightness);
// common anode so invert!
r = map(r, 0, 255, 255, 0);
g = map(g, 0, 255, 255, 0);
b = map(b, 0, 255, 255, 0);
Serial.print("R = "); Serial.print(r, DEC);
Serial.print(" G = "); Serial.print(g, DEC);
Serial.print(" B = "); Serial.println(b, DEC);
analogWrite(REDLITE, r);
analogWrite(GREENLITE, g);
analogWrite(BLUELITE, b);
//read the switch
if(digitalRead(SWitchPIN) == LOW){ //see if switch is being pushed
SWcnt ++; //SW reads low = pushed, increment debounce counter
if(SWcnt >= MAXcnt){ //test if switch is really being pushed AND done bouncing
SWcnt = 0; //done bouncing, reset counter for next push
doorOPEN = !doorOPEN; //reverse desired door state
if(doorOPEN == true){
digitalWrite(LEDPIN, HIGH); //turn LED on
myServo.slowmove(posOpenCMD, slowSPD); //tell servo to go to open position
}
else {
digitalWrite(LEDPIN, LOW); //turn LED off
myServo.slowmove(posCloseCMD, slowSPD); //tell servo to go to closed position
}
}
}
else {
SWcnt = 0; //switch is released or bouncing
}
delay(DBdelay); //wait for next read of switch
}
I think the real challenge will be the adc and implementing that to the lcd though.