Go Down

Topic: My first solo atempt (Read 977 times) previous topic - next topic


Hi All,
I decided to try my hand at my first solo project after going through a chunk of the tutorials.
I also decided to share it with you all, dont laugh I know its crap but its my first go.
Plus if anyone has any tips, tricks, tweaks or advice id be happy to listen.

Code: [Select]
#include <ks0108.h>
#include <Arial14.h>
#include "SystemFont5x7.h"
#include "DICE/ONE.h"
#include "DICE/TWO.h"
#include "DICE/THREE.h"
#include "DICE/FOUR.h"
#include "DICE/FIVE.h"
#include "DICE/SIX.h"
int number;
int button;
void setup(){
  pinMode(42, INPUT);
  GLCD.CursorTo(0, 2);
  GLCD.Puts("Press the button");
  GLCD.CursorTo(0, 4);
  GLCD.Puts("to roll the dice.");

void loop(){
  number = random(1, 7);
  button = digitalRead(42);
  if (button == 1){
    if (number == 1)
       GLCD.DrawBitmap(ONE, 0,0, BLACK);
    if (number == 2)
      GLCD.DrawBitmap(TWO, 0,0, BLACK);
    if (number == 3)
      GLCD.DrawBitmap(THREE, 0,0, BLACK);
    if (number == 4)
      GLCD.DrawBitmap(FOUR, 0,0, BLACK);
    if (number == 5)
      GLCD.DrawBitmap(FIVE, 0,0, BLACK);
    if (number == 6)
      GLCD.DrawBitmap(SIX, 0,0, BLACK);
    GLCD.CursorTo(0, 1);
    GLCD.Puts("Press the button");
    GLCD.CursorTo(0, 3);
    GLCD.Puts("to roll the dice.");


Your pull-down resistor is hooked to the wrong side of the button.  It should connect the input pin to ground.  The button connects the pin to +5.
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131