Using Button to control LED CloudX

  • img
Project Details

Did you know that you can use CloudX M633 to turn on an LED when you press a button? In this project am going to show you how you can use button to ON and OFF Led. when you press the button the led will on, when you press it again the led will off.

Components

  • CloudX M633 with SoftCard
  • USB Cable
  • LED
  • Button switch
  • Jumper wire
  • 10k resistor
  • Breadboard

 

M633

USB Cable

LED

Push Button Switch

Jumper Wires

10k Resistor

 

BreadBoard

 

Circuit Diagram

Code

Copy this Code to your CloudX M633

#include <CloudX/M633.h>
#define BULB pin1
#define Button pin2
bit flag;
setup(){
           //setup here
         pinMode(1, OUTPUT);
         pinMode(2, INPUT);
         BULB = LOW;
loop(){
           //Program here
 
    if(Button == 0 && BULB == LOW){
    delayMs(250);
    BULB = HIGH;         // turn on digital pin 1
    }
    if(Button == 0 && BULB == HIGH ){
    delayMs(250);
    BULB = LOW;          // turn off digital pin 1
    }
  } 
}

Share this with friends