LinkIt ONE Tutorial - Push Button

Introduction

What We’re Doing
We now got an insight of how a software and hardware works from the previous chapter. In this chapter we will learn how to integrate both software and hardware for the control of the LED. Make breadboard connections as shown in the Fig 3.2 and upload the code. Now this circuit operates as a two way switch when you press the left side push button switch the LED glows and when the right side push button is pressed the LED is switched OFF.
Things you need
  • LinkIt One x 1
  • Break board x 1
  • Resistors 330Ω,1kΩ x 1
  • Resistor 10kΩ x 2
  • 5mm LED x 1
  • Transistor(2N3904) x 1
  • Push Button switches x 2
Schematic
Connection
Code
Please click on the button below to download the code for the kit:
You can unzip the file to the Examples folder of your Arduino IDE.
To access the demo code open:
File -> Examples -> Starter Kit for LinkIt -> Basic -> L3_Control_LED_Button
const int pinLED = 3; // LED connect to D13 const int btnOn = 5; // button on const int btnOff = 6; // button off void setup() { pinMode(pinLED, OUTPUT); // set direction of D13-OUTPUT pinMode(btnOff, INPUT); // set direction of D2-INPUT pinMode(btnOn, INPUT); } void loop() { if(0 == digitalRead(btnOn)) // button on pressed { digitalWrite(pinLED, HIGH); } if(0 == digitalRead(btnOff)) { digitalWrite(pinLED, LOW); } }
Making it better
Keeping the same hardware connection upload the following code. The luminosity brightens when the left push button switch is pressed and fades when the right push button switch is pressed.
To access the demo code open::
File -> Examples -> Starter Kit for LinkIt -> Extend_Lesson –> L3_Brightness
More ideas
How will you modify the code such that the blinking frequency of the LED changes?
Reference

Help us make it better

Thank you for choosing Seeed. A couple of months ago we initiated a project to improve our documentation system. What you are looking at now is the first edition of the new documentation system. Comparing to the old one, here is the progresses that we made:
  • Replaced the old documentation system with a new one that was developed from Mkdocs, a more widely used and cooler tool to develop documentation system.
  • Integrated the documentation system with our official website, now you can go to Bazaar and other section like Forum and Community more conveniently.
  • Reviewed and rewrote documents for hundreds of products for the system’s first edition, and will continue migrate documents from old wiki to the new one.
An easy-to-use instruction is as important as the product itself. We are expecting this new system will improve your experience when using Seeed’s products. However since this is the first edition, there are still many things need to improve, if you have any suggestions or findings, you are most welcome to submit the amended version as our contributor or give us suggestions in the survey below, Please don’t forget to leave your email address so that we can reply.
Happy hacking