Skill Dev II

Made by Emily Liu · UNLISTED (SHOWN IN POOLS)

Created: December 12th, 2021

0

Prepare a simple 2-in (sensors or inputs) 1-out (LED) device (i.e. your project will use three components (resistors and wire don't count!) and at least one must be a sensor). Present a really simple use case for a connected sensor device.

0

Button -> LED

0
// We will be using D2 to control our LED
int ledPin = D2;

// Our button wired to D0
int buttonPin = D3;

void setup()
{

  // For input, we define the
  // pushbutton as an input-pullup
  // this uses an internal pullup resistor
  // to manage consistent reads from the device

  pinMode( buttonPin , INPUT_PULLUP); // sets pin as input

  // We also want to use the LED

  pinMode( ledPin , OUTPUT ); // sets pin as output

}

void loop()
{
   // find out if the button is pushed
   // or not by reading from it.
   int buttonState = digitalRead( buttonPin );

  // remember that we have wired the pushbutton to
  // ground and are using a pulldown resistor
  // that means, when the button is pushed,
  // we will get a LOW signal
  // when the button is not pushed we'll get a HIGH

  // let's use that to set our LED on or off

  if( buttonState == LOW )
  {
    // turn the LED On
    digitalWrite( ledPin, HIGH);
  }else{
    // otherwise
    // turn the LED Off
    digitalWrite( ledPin, LOW);

  }


}
Click to Expand
0

Button -> photoresistor -> LED

0
Click to Expand
0

Switch turns on LED

0
nt ledPin = D2;
int switchPin = D3;
int ledBrightness = 0;
// int photoCellPin = A0;
// int photoCellReading = 0;

void setup()
{


  pinMode( switchPin , INPUT_PULLUP); // sets pin as input

  // We also want to use the LED

  pinMode( ledPin , OUTPUT ); // sets pin as output

}

void loop()
{
   // find out if the button is pushed
   // or not by reading from it.
   int buttonState = digitalRead( switchPin );

  // Using a pulldown resistor we get a LOW
  // Signal when its on
  
  if( buttonState == HIGH )
  {
     digitalWrite( ledPin, HIGH);
  }else{
    // otherwise
    // turn the LED Off
    digitalWrite( ledPin, LOW);
  
  }
Click to Expand
0

Switch turns on photoresistor to turn off LED

0
Click to Expand
0
IMG 4091
Emily Liu - https://youtu.be/tCDpAtjTZTE
x
Share this Project

This project is only listed in this pool. Be considerate and think twice before sharing.


Courses

About

~