author
7Instructables254,445Views3CommentsNortheast USJoined March 11th, 2009

Tell us about yourself!

Complete Your Profile

Achievements

10K+ Views Earned a bronze medal
  • Arduino Basketball Pop-a-Shot: Upgrayedd

    Here's an update to this project with the following modifications: Uses an Arduino Uno Uses a 7-segment display (not alpha-numeric) Adds a momentary button to reset the counterHave fun!// Documentation: https://cdn-learn.adafruit.com/downloads/pdf/adaf...//include libraries#include "Adafruit_LEDBackpack.h"#include "Adafruit_GFX.h"// create Adafruit Alphanumeric Display object// NOTE: The AlphaNum4 uses '//Adafruit_AlphaNum4 matrix = Adafruit_AlphaNum4();Adafruit_7segment matrix = Adafruit_7segment();// The button is connected to PIN 3 for the internal pullup resistorconst int buttonPin = 3;// define integerint score = 0;// button debounce variablesbool buttonState;bool lastButtonState = HIGH;unsigned long lastDebounceTime = 0;unsigne...

    see more »

    Here's an update to this project with the following modifications: Uses an Arduino Uno Uses a 7-segment display (not alpha-numeric) Adds a momentary button to reset the counterHave fun!// Documentation: https://cdn-learn.adafruit.com/downloads/pdf/adaf...//include libraries#include "Adafruit_LEDBackpack.h"#include "Adafruit_GFX.h"// create Adafruit Alphanumeric Display object// NOTE: The AlphaNum4 uses '//Adafruit_AlphaNum4 matrix = Adafruit_AlphaNum4();Adafruit_7segment matrix = Adafruit_7segment();// The button is connected to PIN 3 for the internal pullup resistorconst int buttonPin = 3;// define integerint score = 0;// button debounce variablesbool buttonState;bool lastButtonState = HIGH;unsigned long lastDebounceTime = 0;unsigned long debounceDelay = 30;void writeScore(int score) { Serial.print("score: "); Serial.println(score); //write score to display data matrix.writeDigitNum(4, (score%10)); matrix.writeDigitNum(3, (score%100/10)); matrix.drawColon(false); matrix.writeDigitNum(1, (score%1000/100)); matrix.writeDigitNum(0, (score/1000)); //push display data to display matrix.writeDisplay();}void setup() { //set sensor pin to INPUT pinMode(A0, INPUT); //set button pin to INPUT_PULLUP, see: https://www.arduino.cc/reference/en/language/func... pinMode(buttonPin, INPUT_PULLUP); //set BAUD rate Serial.begin(9600); //start display matrix.begin(0x70); //write zeros to all positions writeScore(0); //display newly written values matrix.writeDisplay();}void loop() { // debounce reset button // for more information, check out Arduino > Examples > 02 Digital > Debounce int reading = digitalRead(buttonPin); if (reading != lastButtonState) { lastDebounceTime = millis(); } if ((millis() - lastDebounceTime) > debounceDelay) { if (reading != buttonState) { buttonState = reading; if (buttonState == LOW) { // we are pulling up the input pin score = 0; writeScore(score); } } } lastButtonState = reading; //add 1 to the score if sensor voltage is LOW if (analogRead(A0) < 200) { score++; //write score to display data writeScore(score); //wait 1.5 sec to eliminate phantom reads // NOTE: This will interfere with the "RESET" button // As a notice for this delay, we enable the colons matrix.drawColon(true); matrix.writeDisplay(); delay(1000); matrix.drawColon(false); matrix.writeDisplay(); }}

    View Instructable »