GithubHelp home page GithubHelp logo

j823's Projects

maker-dtc338 icon maker-dtc338

Maker Culture: Class Syllabus, Examples, References, Materials - Spring 2015

pushbuttoncontrol icon pushbuttoncontrol

// Example 03B: Turned an LED on and off with a button // I copied this code and changed the LED and Buttons after having trouble // with the redboard //started by watching many Youtube videos and web researching //feels like I'm finally understanding //started with wires, green LED, pentontemeter, resitor, arduino examples, //redboard, breadboard //pentontometer exchanged for button to complete circuit, something wasnt working //many failures experienced before lighting the LED //due to possibly not uploading the example sketch for the board correctly //what changed was that sketch was uploade correctly, the one from github //after a lot of relief from board working correctly decided to just switch pins //pin 13 was switched for 12 and I dont remember what pin 8 was switched from //I ended up with the board and LED wprking correctly //was begining to think my board was damaged somehow possibly due to shipment //This project has and will continue to lead to a greater understanding of boards //and electronics for me //and I hope others as well //GOOD NIGHT, AND THANK YOU FOR ATTENDING, DTC 338 VANCOUVER!!! #define LED 12 // LED pin #define BUTTON 8 // input pin for Pushbutton int val = 0; // val will be used to store the state // of the input pin int old_val = 0; // this variable stores the previous // value of "val" int state = 0; // 0 = LED off and 1 = LED on void setup() { pinMode(LED, OUTPUT); // tell Arduino LED is an output pinMode(BUTTON, INPUT); // and BUTTON is an input } void loop(){ val = digitalRead(BUTTON); // read input value and store it // check if there was a transition if ((val == HIGH) && (old_val == LOW)){ state = 1 - state; } old_val = val; // val is now old, let's store it if (state == 1) { digitalWrite(LED, HIGH); // turn LED ON } else { digitalWrite(LED, LOW); } }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.