Hi everyone,
Just started with Arduino and made a few small projects but since I am no programmer I hit a dead end pretty quick on my current project involving a 8x8 LED Matrix backpack driven by Gemma from Adafruit.
Project description: press a button; wake up the 8x8 LED Matrix; display a picture for 5 sec. and go back to sleep. If the button is pressed again before the sleep mode (5 sec.) go to next picture in library and show it on the matrix and so on so forth. Basically is changing the picture after every button press.
Schematics:
Full project description:
=https://learn.adafruit.com/trinket-slash-gemma-space-invader-pendant/overview
My post on Adafruit forum with no response except mine:
=https://forums.adafruit.com/viewtopic.php?f=51&t=77191
So my biggest problem is the coding side, if any one could help/advice I would greatly appreciate it.
Thanks!
Catalin
My code:
/***************************************************
This is a library for our I2C LED Backpacks
Designed specifically to work with the Adafruit LED Matrix backpacks
----> http://www.adafruit.com/products/872
----> http://www.adafruit.com/products/871
----> http://www.adafruit.com/products/870
These displays use I2C to communicate, 2 pins are required to
interface. There are multiple selectable I2C addresses. For backpacks
with 2 Address Select pins: 0x70, 0x71, 0x72 or 0x73. For backpacks
with 3 Address Select pins: 0x70 thru 0x77
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, all text above must be included in any redistribution
****************************************************/
#include <Wire.h>
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"
// Button pin
const int buttonPin = 1;
Adafruit_8x8matrix matrix = Adafruit_8x8matrix();
void setup() {
Serial.begin(9600);
//Serial.println("8x8 LED Matrix Test");
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
matrix.begin(0x70); // pass in the address
}
static const uint8_t PROGMEM
smile_bmp[] =
{ B00111100,
B01000010,
B10100101,
B10000001,
B10100101,
B10011001,
B01000010,
B00111100 },
neutral_bmp[] =
{ B00111100,
B01000010,
B10100101,
B10000001,
B10111101,
B10000001,
B01000010,
B00111100 },
frown_bmp[] =
{ B00111100,
B01000010,
B10100101,
B10000001,
B10011001,
B10100101,
B01000010,
B00111100 };
void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
bitmap_count = bitmap_count +1;
if (bitmap_count == 3){bitmap_count = 1;}
}
switch (bitmap_count){
case 1:
// bitmap 1 code here
matrix.clear();
matrix.drawBitmap(0, 0, smile_bmp, 8, 8, LED_ON);
matrix.writeDisplay();
break;
case 2:
//bitmap 2 code here
matrix.clear();
matrix.drawBitmap(0, 0, neutral_bmp, 8, 8, LED_ON);
matrix.writeDisplay();
break;
case 3:
//bitmap 3 code here
matrix.clear();
matrix.drawBitmap(0, 0, frown_bmp, 8, 8, LED_ON);
matrix.writeDisplay();
break;
} // end switch
} // end void loop