Trick Switch with On/Off Indicators using Arduino microcontroller

Trick Switch with On/Off Indicators using Arduino microcontroller

Please see the basic design of Trick Switch using Arduino microcontroller

In developing new products, electronics designers are always improving designs by adding features and functions that excite the customer. The Trick Switch device you built can be improved by adding an LED indicator. This LED indicates when the Trick Switch timing cycle is done. Figure 1-3 shows you where to add a green LED to the Trick Switch on the full-size clear breadboard.

Adding a green LED indicator to the Trick Switch circuit built on a full-size clear breadboard
Figure 1-3. Adding a green LED indicator to the Trick Switch circuit built on a full-size clear breadboard

To complete the new product design, you need to make a few changes to the Pushbutton sketch. Modify the sketch using the code changes shown in Example 1-2.

Example 1-2. Pushbutton sketch modified to include LED indicators

// constants won't change; they're used here to
// set pin numbers:
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 12; // the number of the LED pin
const int ledPin13 = 13; // onboard LED
void setup() {
// initialize the LED pins as outputs:
pinMode(ledPin, OUTPUT);
pinMode(ledPin13, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}
void loop(){
// read the state of the pushbutton value:
int buttonStatus;
buttonStatus = digitalRead(buttonPin);
// check if the pushbutton is pressed
// if it is, the buttonStatus is HIGH:
if (buttonStatus == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
// turn off onboard LED:
digitalWrite(ledPin13,LOW);
}
else {
// turn LED off:
digitalWrite(ledPin, LOW);
// turn on onboard LED:
digitalWrite(ledPin13, HIGH);
}
}

After you’ve saved the sketch changes and uploaded them to the Arduino, the green LED will turn on. When you press the mini pushbutton, the green LED will turn off, and the red LED will turn on. Pretty awesome stuff. Enjoy!

The block diagram in Figure 1-4 shows the electronic component blocks and the electrical signal flow for the Trick Switch. A Fritzing electronic circuit schematic diagram of the switch is shown in Figure 1-5. Electronic circuit schematic diagrams are used by electrical/electronic engineers to design and build cool electronic products for society.

Trick Switch block diagram
Figure 1-4. Trick Switch block diagram

Something to Think About

Try different resistor and capacitor values and see what happens. Can you detect any patterns? How can a small piezo buzzer be used with the Trick Switch?

Trick Switch circuit schematic diagram
Figure 1-5. Trick Switch circuit schematic diagram

 

Book Reference: Make: Basic Arduino Projects
26 Experiments with Microcontrollers and Electronics
By: Don Wilcher

ইঞ্জিনিয়ার ছাত্র ছাত্রীদের প্রাক্টিকাল কাজ করার জন্য সকল ধরনের ইঞ্জিনিয়ারিং প্রোডাক্ট স্বল্প মূল্যে ঘরে বসে পেতে এখনি ভিজিট করুন উপকরণ ডট কমে। ইঞ্জিনিয়ার ছাত্র ছাত্রীরা একবার হলেও এই ওয়েবসাইটি দেখে আসুন। এখানে ক্লিক করুন www.upokoron.com

Write Your Comments

comments

Leave a Reply