With the help of some very patient and considerate helpers in this forum I created a switch to turn on my 12v LED reading light panel when I sit on the chair. [Chair Occupancy Light Switch - #12 by ec2021]
I’m pretty much a nubie and have no intention of creating more than this one device for my own use. An Arduino Uno 3 on a breadboard, alligator clips, jumper wires, and long wires certainly can’t be what I end up with. Now what? How do I convert this jumble to a real device?
Here’s the Tinkercad image. (seat sensor switch, 12v ac/dc wall adapter, and my 12v LED light panel components not available on Tinker are shown as a pushbutton switch, 9v battery, and dc motor respectively.)
FWIW, here’s the code that’s working:
/* this sketch uses a occupancy switch to turn
on a 12v Led reading light when the seat is occupied */
// using Arduino Uno 3
// from arduino forum https://forum.arduino.cc/t/pressure-sensor/546144/4
// using sea tsensor that looks like mine
const byte switchPin = 2; // connect the switch to pin 2, the other side to ground
const byte ledPin = 13; // use the built-in LED as an indicator
const byte LightsPin = 3; // this pin sends signal to Mosfet to turn on 12 volt LED light panel
byte SwitchRead; // variable to store value of the Seat Occupancy Switch
void setup() {
pinMode(switchPin, INPUT_PULLUP);
pinMode(ledPin, OUTPUT);
pinMode(LightsPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
SwitchRead = !digitalRead(switchPin);
digitalWrite(ledPin, SwitchRead);
digitalWrite(LightsPin, SwitchRead);
Serial.println(SwitchRead);
}
I’ll get rid of the Serial stuff once I finalize this project.
Since I’m only using 1 input pin and 2 output pins on the Arduino, I figure that’s expensive overkill. Before this, last I dabbled in electronics and gave up, I pushed a buy button and ended up with some items some of which I thought might be useful in this next stage:
- Several Digispark Pro Kickstarter Development Board USB Micro ATTINY167 Module from Banggood
- Several what look like “ Digispark Kickstarter Micro Usb Development Board For ATTINY85” also apparently from Banggood
- Adafruit Trinket MO,
And from deep in long forgotten storage bins:
- Radio Shack General Purpose IC PC Board,
- Radio Shack Prepunched Perfboard, and
- Solder
Any help or guidance is much appreciated,
Thanks,
Hal