5% OFF Over $19, Code: Elephant5; 10% OFF Over $59, Code: Elephant10



ARDUBLOCK Project 15: Tilting Switch Module

Posted by Fiona Su on

Introduction:
When one side of the switch tilts below horizontal position, the switch is on; When the other side of the switch tilts below horizontal position, the switch is off.
In the project, we use graphical programming to control the on and off of LED, tilting module used as a button.
Materials Required:

  • 1. KEYESTUDIO UNO Control Board *1
  • 2. V5 Sensor Shield*1
  • 3. Piranha LED*1
  • 4. Tilting Switch Module*1
  • 5. Female to Female Dupont Line*6

Connection Diagram:

thumb

 

thumb

After wiring, we can start programming.

thumb

Click “download to Arduino” to see the following codes in IDE interface:
Sample Code:

*****************************************************************************
void setup()
{
  pinMode( 3 , INPUT);
  pinMode( 6 , OUTPUT);
}

void loop()
{
  if (( digitalRead(3) && HIGH ))
  {
    digitalWrite( 6 , HIGH );
    delay( 100 );
  }
  else
  {
    digitalWrite( 6 , LOW );
    delay( 100 );
  }
}
*******************************************************************************

Result:
After the program is downloaded, we can use tilting switch module to control LED.

All Projects

Buy it >> ARDUBLOCK Graphical Programming Starter Kit for Arduino

 

0 comments

Leave a comment

Please note, comments must be approved before they are published