Pages: [1]   Go Down
Author Topic: code check for me please  (Read 1017 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hello everyone i am in the middle of making a LED screen for a project that needs to show a different image for each separate button press.
i will have 5-6 buttons.
 5-6 images.
i have figured out how to code out the images and have gotten them to display properly on the 16x24 display that i have.

now what i need to know is:
a.  how to add button presses to the code to make them "if statements" (??)
b. how to upload the code to the arduino to make it portable. (already have it powered up w/ battery pack but i would like to have the code be onboard so i dont have to upload from computer)
      -also afraid i will overwrite something important if my code doesnt have everything...
c. there has got to be a way to make this code better, but right now everything fits just fine so i guess its ok.
d. im guessing im going to need to incorporate an on/off switch into this too

and yes i am very new to this. but hot damn- i have all this written and i picked this up 2 days ago

code in next post



* 575875_3317145879842_1004097224_33015214_1879466612_n.jpg (56.54 KB, 720x540 - viewed 14 times.)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
#include "HT1632.h"

#define DATA 2
#define WR   3
#define CS   4
#define CS2  5

// use this line for single matrix
HT1632LEDMatrix matrix = HT1632LEDMatrix(DATA, WR, CS);
// use this line for two matrices!
//HT1632LEDMatrix matrix = HT1632LEDMatrix(DATA, WR, CS, CS2);

void setup() {
  Serial.begin(9600);
  matrix.begin(HT1632_COMMON_16NMOS);  

}

void loop() {
  //-------insert button press switch command here-----------
  
  matrix.clearScreen();
   // draw a big zer0!

  matrix.drawPixel(3, 0, 2);
  matrix.drawPixel(4, 0, 2);
  matrix.drawPixel(5, 0, 2);
  matrix.drawPixel(6, 0, 2);
  matrix.drawPixel(7, 0, 2);
  matrix.drawPixel(8, 0, 2);
  matrix.drawPixel(9, 0, 2);
  matrix.drawPixel(10, 0, 2);
  matrix.drawPixel(11, 0, 2);
  matrix.drawPixel(12, 0, 1);
  matrix.drawPixel(13, 0, 2);
  matrix.drawPixel(14, 0, 2);
  matrix.drawPixel(15, 0, 2);
  matrix.drawPixel(16, 0, 2);
  matrix.drawPixel(17, 0, 2);
  matrix.drawPixel(18, 0, 2);
  matrix.drawPixel(19, 0, 2);
  matrix.drawPixel(20, 0, 2);

  

  matrix.drawPixel(2, 1, 2);
  matrix.drawPixel(3, 1, 2);
  matrix.drawPixel(4, 1, 2);
  matrix.drawPixel(5, 1, 2);
  matrix.drawPixel(6, 1, 2);
  matrix.drawPixel(7, 1, 2);
  matrix.drawPixel(8, 1, 2);
  matrix.drawPixel(9, 1, 2);
  matrix.drawPixel(10, 1, 2);
  matrix.drawPixel(11, 1, 2);
  matrix.drawPixel(12, 1, 1);
  matrix.drawPixel(13, 1, 2);
  matrix.drawPixel(14, 1, 2);
  matrix.drawPixel(15, 1, 2);
  matrix.drawPixel(16, 1, 2);
  matrix.drawPixel(17, 1, 2);
  matrix.drawPixel(18, 1, 2);
  matrix.drawPixel(19, 1, 2);
  matrix.drawPixel(20, 1, 2);
  matrix.drawPixel(21, 1, 2);

  
 
  matrix.drawPixel(1, 2, 2);
  matrix.drawPixel(2, 2, 2);
  matrix.drawPixel(3, 2, 2);
  matrix.drawPixel(4, 2, 2);
  matrix.drawPixel(5, 2, 2);
  matrix.drawPixel(6, 2, 2);
  matrix.drawPixel(7, 2, 2);
  matrix.drawPixel(8, 2, 2);
  matrix.drawPixel(9, 2, 2);
  matrix.drawPixel(10, 2, 2);
  matrix.drawPixel(11, 2, 2);
  matrix.drawPixel(12, 2, 1);
  matrix.drawPixel(13, 2, 2);
  matrix.drawPixel(14, 2, 2);
  matrix.drawPixel(15, 2, 2);
  matrix.drawPixel(16, 2, 2);
  matrix.drawPixel(17, 2, 2);
  matrix.drawPixel(18, 2, 2);
  matrix.drawPixel(19, 2, 2);
  matrix.drawPixel(20, 2, 2);
  matrix.drawPixel(21, 2, 2);
  matrix.drawPixel(22, 2, 2);
 
  
    matrix.drawPixel(0, 3, 2);
  matrix.drawPixel(1, 3, 2);
  matrix.drawPixel(2, 3, 2);
  matrix.drawPixel(6, 3, 2);
  matrix.drawPixel(7, 3, 2);
  matrix.drawPixel(8, 3, 2);
  matrix.drawPixel(21, 3, 2);
  matrix.drawPixel(22, 3, 2);
  matrix.drawPixel(23, 3, 2);
  
    matrix.drawPixel(0, 4, 2);
  matrix.drawPixel(1, 4, 2);
  matrix.drawPixel(2, 4, 2);
  matrix.drawPixel(7, 4, 2);
  matrix.drawPixel(8, 4, 2);
  matrix.drawPixel(9, 4, 2);
  matrix.drawPixel(21, 4, 2);
  matrix.drawPixel(22, 4, 2);
  matrix.drawPixel(23, 4, 2);
  
    matrix.drawPixel(0, 5, 2);
  matrix.drawPixel(1, 5, 2);
  matrix.drawPixel(2, 5, 2);
  matrix.drawPixel(8, 5, 2);
  matrix.drawPixel(9, 5, 2);
  matrix.drawPixel(10, 5, 2);
  matrix.drawPixel(21, 5, 2);
  matrix.drawPixel(22, 5, 2);
  matrix.drawPixel(23, 5, 2);
  
    matrix.drawPixel(0, 6, 2);
  matrix.drawPixel(1, 6, 2);
  matrix.drawPixel(2, 6, 2);
    matrix.drawPixel(9, 6, 2);
  matrix.drawPixel(10, 6, 2);
  matrix.drawPixel(11, 6, 2);
   matrix.drawPixel(21, 6, 2);
  matrix.drawPixel(22, 6, 2);
  matrix.drawPixel(23, 6, 2);
  
    matrix.drawPixel(0, 7, 2);
  matrix.drawPixel(1, 7, 2);
  matrix.drawPixel(2, 7, 2);
  matrix.drawPixel(10, 7, 2);
  matrix.drawPixel(11, 7, 2);
  matrix.drawPixel(12, 7, 2);
  matrix.drawPixel(21, 7, 2);
  matrix.drawPixel(22, 7, 2);
  matrix.drawPixel(23, 7, 2);
  
    matrix.drawPixel(0, 8, 2);
  matrix.drawPixel(1, 8, 2);
  matrix.drawPixel(2, 8, 2);
  matrix.drawPixel(11, 8, 2);
  matrix.drawPixel(12, 8, 2);
  matrix.drawPixel(13, 8, 2);
  matrix.drawPixel(21, 8, 2);
  matrix.drawPixel(22, 8, 2);
  matrix.drawPixel(23, 8, 2);
  
    matrix.drawPixel(0, 9, 2);
  matrix.drawPixel(1, 9, 2);
  matrix.drawPixel(2, 9, 2);
  matrix.drawPixel(12, 9, 2);
  matrix.drawPixel(13, 9, 2);
  matrix.drawPixel(14, 9, 2);
  matrix.drawPixel(21, 9, 2);
  matrix.drawPixel(22, 9, 2);
  matrix.drawPixel(23, 9, 2);
  
    matrix.drawPixel(0, 10, 2);
  matrix.drawPixel(1, 10, 2);
  matrix.drawPixel(2, 10, 2);
  matrix.drawPixel(13, 10, 2);
  matrix.drawPixel(14, 10, 2);
  matrix.drawPixel(15, 10, 2);
  matrix.drawPixel(21, 10, 2);
  matrix.drawPixel(22, 10, 2);
  matrix.drawPixel(23, 10, 2);
  
      matrix.drawPixel(0, 11, 2);
  matrix.drawPixel(1, 11, 2);
  matrix.drawPixel(2, 11, 2);
  matrix.drawPixel(14, 11, 2);
  matrix.drawPixel(15, 11, 2);
  matrix.drawPixel(16, 11, 2);
  matrix.drawPixel(21, 11, 2);
  matrix.drawPixel(22, 11, 2);
  matrix.drawPixel(23, 11, 2);
  
      matrix.drawPixel(0, 12, 2);
  matrix.drawPixel(1, 12, 2);
  matrix.drawPixel(2, 12, 2);
  matrix.drawPixel(15, 12, 2);
  matrix.drawPixel(16, 12, 2);
  matrix.drawPixel(17, 12, 2);
  matrix.drawPixel(21, 12, 2);
  matrix.drawPixel(22, 12, 2);
  matrix.drawPixel(23, 12, 2);
  
 
  matrix.drawPixel(1, 13, 2);
  matrix.drawPixel(2, 13, 2);
  matrix.drawPixel(3, 13, 2);
  matrix.drawPixel(4, 13, 2);
  matrix.drawPixel(5, 13, 2);
  matrix.drawPixel(6, 13, 2);
  matrix.drawPixel(7, 13, 2);
  matrix.drawPixel(8, 13, 2);
  matrix.drawPixel(9, 13, 2);
  matrix.drawPixel(10, 13, 2);
  matrix.drawPixel(11, 13, 2);
  matrix.drawPixel(12, 13, 2);
  matrix.drawPixel(13, 13, 2);
  matrix.drawPixel(14, 13, 2);
  matrix.drawPixel(15, 13, 2);
  matrix.drawPixel(16, 13, 2);
  matrix.drawPixel(17, 13, 2);
  matrix.drawPixel(18, 13, 2);
  matrix.drawPixel(19, 13, 2);
  matrix.drawPixel(20, 13, 2);
  matrix.drawPixel(21, 13, 2);
  matrix.drawPixel(22, 13, 2);

  

  matrix.drawPixel(2, 14, 2);
  matrix.drawPixel(3, 14, 2);
  matrix.drawPixel(4, 14, 2);
  matrix.drawPixel(5, 14, 2);
  matrix.drawPixel(6, 14, 2);
  matrix.drawPixel(7, 14, 2);
  matrix.drawPixel(8, 14, 2);
  matrix.drawPixel(9, 14, 2);
  matrix.drawPixel(10, 14, 2);
  matrix.drawPixel(11, 14, 2);
  matrix.drawPixel(12, 14, 2);
  matrix.drawPixel(13, 14, 2);
  matrix.drawPixel(14, 14, 2);
  matrix.drawPixel(15, 14, 2);
  matrix.drawPixel(16, 14, 2);
  matrix.drawPixel(17, 14, 2);
  matrix.drawPixel(18, 14, 2);
  matrix.drawPixel(19, 14, 2);
  matrix.drawPixel(20, 14, 2);
  matrix.drawPixel(21, 14, 2);

  

  matrix.drawPixel(3, 15, 2);
  matrix.drawPixel(4, 15, 2);
  matrix.drawPixel(5, 15, 2);
  matrix.drawPixel(6, 15, 2);
  matrix.drawPixel(7, 15, 2);
  matrix.drawPixel(8, 15, 2);
  matrix.drawPixel(9, 15, 2);
  matrix.drawPixel(10, 15, 2);
  matrix.drawPixel(11, 15, 2);
  matrix.drawPixel(12, 15, 2);
  matrix.drawPixel(13, 15, 2);
  matrix.drawPixel(14, 15, 2);
  matrix.drawPixel(15, 15, 2);
  matrix.drawPixel(16, 15, 2);
  matrix.drawPixel(17, 15, 2);
  matrix.drawPixel(18, 15, 2);
  matrix.drawPixel(19, 15, 2);
  matrix.drawPixel(20, 15, 2);

  matrix.writeScreen();
  
   delay(3000);
  
     matrix.clearScreen();
  
  //-------insert button press switch command here-----------
  
  matrix.clearScreen();
   // draw a smiley!

  matrix.drawPixel(8, 2, 2);
  matrix.drawPixel(9, 2, 2);
  matrix.drawPixel(14, 2, 2);
  matrix.drawPixel(15, 2, 2);

  
  matrix.drawPixel(8, 3, 2);
  matrix.drawPixel(9, 3, 2);
  matrix.drawPixel(14, 3, 2);
  matrix.drawPixel(15, 3, 2);

 
  matrix.drawPixel(8, 4, 2);
  matrix.drawPixel(9, 4, 2);
  matrix.drawPixel(14, 4, 2);
  matrix.drawPixel(15, 4, 2);

  
  matrix.drawPixel(8, 5, 2);
  matrix.drawPixel(9, 5, 2);
  matrix.drawPixel(14, 5, 2);
  matrix.drawPixel(15, 5, 2);
  
 
  matrix.drawPixel(4, 9, 2);
  matrix.drawPixel(5, 9, 2);
  matrix.drawPixel(18, 9, 2);
  matrix.drawPixel(19, 9, 2);

  
  matrix.drawPixel(5, 10, 2);
  matrix.drawPixel(6, 10, 2);
  matrix.drawPixel(17, 10, 2);
  matrix.drawPixel(18, 10, 2);

  
  
  matrix.drawPixel(6, 11, 2);
  matrix.drawPixel(7, 11, 2);
  matrix.drawPixel(8, 11, 2);
  matrix.drawPixel(9, 11, 2);
  matrix.drawPixel(10, 11, 2);
  matrix.drawPixel(11, 11, 2);
  matrix.drawPixel(12, 11, 1);
  matrix.drawPixel(13, 11, 2);
  matrix.drawPixel(14, 11, 2);
  matrix.drawPixel(15, 11, 2);
  matrix.drawPixel(16, 11, 2);
  matrix.drawPixel(17, 11, 2);

  
 
  matrix.drawPixel(7, 12, 2);
  matrix.drawPixel(8, 12, 2);
  matrix.drawPixel(9, 12, 2);
  matrix.drawPixel(10, 12, 2);
  matrix.drawPixel(11, 12, 2);
  matrix.drawPixel(12, 12, 1);
  matrix.drawPixel(13, 12, 2);
  matrix.drawPixel(14, 12, 2);
  matrix.drawPixel(15, 12, 2);
  matrix.drawPixel(16, 12, 2);

  matrix.writeScreen();
  
   delay(3000);
  
     matrix.clearScreen();
 
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
 //-------insert button press switch command here-----------
  
  matrix.clearScreen();
   // draw a frown!
  
    
  matrix.drawPixel(8, 2, 2);
  matrix.drawPixel(9, 2, 2);
  matrix.drawPixel(14, 2, 2);
  matrix.drawPixel(15, 2, 2);

  
  matrix.drawPixel(8, 3, 2);
  matrix.drawPixel(9, 3, 2);
  matrix.drawPixel(14, 3, 2);
  matrix.drawPixel(15, 3, 2);
  
  
  matrix.drawPixel(8, 4, 2);
  matrix.drawPixel(9, 4, 2);
  matrix.drawPixel(14, 4, 2);
  matrix.drawPixel(15, 4, 2);
  
  matrix.drawPixel(8, 5, 2);
  matrix.drawPixel(9, 5, 2);
  matrix.drawPixel(14, 5, 2);
  matrix.drawPixel(15, 5, 2);
  
    matrix.drawPixel(7, 9, 2);
  matrix.drawPixel(8, 9, 2);
  matrix.drawPixel(9, 9, 2);
  matrix.drawPixel(10, 9, 2);
  matrix.drawPixel(11, 9, 2);
  matrix.drawPixel(12, 9, 1);
  matrix.drawPixel(13, 9, 2);
  matrix.drawPixel(14, 9, 2);
  matrix.drawPixel(15, 9, 2);
  matrix.drawPixel(16, 9, 2);
  
 
  matrix.drawPixel(6, 10, 2);
  matrix.drawPixel(7, 10, 2);
  matrix.drawPixel(8, 10, 2);
  matrix.drawPixel(9, 10, 2);
  matrix.drawPixel(10, 10, 2);
  matrix.drawPixel(11, 10, 2);
  matrix.drawPixel(12, 10, 1);
  matrix.drawPixel(13, 10, 2);
  matrix.drawPixel(14, 10, 2);
  matrix.drawPixel(15, 10, 2);
  matrix.drawPixel(16, 10, 2);
  matrix.drawPixel(17, 10, 2);

  
  
  matrix.drawPixel(5, 11, 2);
  matrix.drawPixel(6, 11, 2);
  matrix.drawPixel(17, 11, 2);
  matrix.drawPixel(18, 11, 2);
  
 
  matrix.drawPixel(4, 12, 2);
  matrix.drawPixel(5, 12, 2);
  matrix.drawPixel(18, 12, 2);
  matrix.drawPixel(19, 12, 2);

  matrix.writeScreen();
  
   delay(3000);
  
     matrix.clearScreen();
    
      //-------insert button press switch command here-----------
  
  matrix.clearScreen();
   // draw danger!


  matrix.drawPixel(18, 0, 2);
  matrix.drawPixel(19, 0, 2);
  

  matrix.drawPixel(16, 1, 2);
  matrix.drawPixel(17, 1, 2);
  matrix.drawPixel(19, 1, 2);
  

  matrix.drawPixel(14, 2, 2);
  matrix.drawPixel(15, 2, 2);
  matrix.drawPixel(19, 2, 2);


  matrix.drawPixel(12, 3, 1);
  matrix.drawPixel(13, 3, 2);
  matrix.drawPixel(19, 3, 2);

  

  matrix.drawPixel(10, 4, 2);
  matrix.drawPixel(11, 4, 2);
  matrix.drawPixel(19, 4, 2);

 
  matrix.drawPixel(8, 5, 2);
  matrix.drawPixel(9, 5, 2);
  matrix.drawPixel(19, 5, 2);

  matrix.drawPixel(6, 6, 2);
  matrix.drawPixel(7, 6, 2);
  matrix.drawPixel(19, 6, 2);

 
  matrix.drawPixel(5, 7, 2);
  matrix.drawPixel(9, 7, 2);
  matrix.drawPixel(10, 7, 2);
  matrix.drawPixel(11, 7, 2);
  matrix.drawPixel(12, 7, 1);
  matrix.drawPixel(13, 7, 2);
  matrix.drawPixel(14, 7, 2);
  matrix.drawPixel(16, 7, 2);
  matrix.drawPixel(17, 7, 2);
  matrix.drawPixel(19, 7, 2);

  
  
  matrix.drawPixel(5, 8, 2);
  matrix.drawPixel(9, 8, 2);
  matrix.drawPixel(10, 8, 2);
  matrix.drawPixel(11, 8, 2);
  matrix.drawPixel(12, 8, 1);
  matrix.drawPixel(13, 8, 2);
  matrix.drawPixel(14, 8, 2);
  matrix.drawPixel(16, 8, 2);
  matrix.drawPixel(17, 8, 2);
  matrix.drawPixel(19, 8, 2);


  matrix.drawPixel(6, 9, 2);
  matrix.drawPixel(7, 9, 2);
  matrix.drawPixel(19, 9, 2);

  
  
  matrix.drawPixel(8, 10, 2);
  matrix.drawPixel(9, 10, 2);
  matrix.drawPixel(19, 10, 2);

  
 
  matrix.drawPixel(10, 11, 2);
  matrix.drawPixel(11, 11, 2);
  matrix.drawPixel(19, 11, 2);

  
  matrix.drawPixel(12, 12, 1);
  matrix.drawPixel(13, 12, 2);
  matrix.drawPixel(19, 12, 2);

  
  
  matrix.drawPixel(14, 13, 2);
  matrix.drawPixel(15, 13, 2);
  matrix.drawPixel(19, 13, 2);

  
  matrix.drawPixel(16, 14, 2);
  matrix.drawPixel(17, 14, 2);
  matrix.drawPixel(19, 14, 2);

  

  matrix.drawPixel(18, 15, 2);
  matrix.drawPixel(19, 15, 2);


  matrix.writeScreen();
  
   delay(3000);
  
     matrix.clearScreen();
    
           //-------insert button press switch command here-----------
  
  matrix.clearScreen();
   // draw ?
  matrix.drawPixel(5, 1, 2);
  matrix.drawPixel(6, 1, 2);
  matrix.drawPixel(7, 1, 2);
  matrix.drawPixel(8, 1, 2);
 
  matrix.drawPixel(3, 2, 2);
  matrix.drawPixel(4, 2, 2);
  matrix.drawPixel(5, 2, 2);
  matrix.drawPixel(6, 2, 2);
  matrix.drawPixel(7, 2, 2);
  matrix.drawPixel(8, 2, 2);
  matrix.drawPixel(9, 2, 2);
  matrix.drawPixel(10, 2, 2);
 
  matrix.drawPixel(3, 3, 2);
  matrix.drawPixel(4, 3, 2);
  matrix.drawPixel(5, 3, 2);
  matrix.drawPixel(6, 3, 2);
  matrix.drawPixel(7, 3, 2);
  matrix.drawPixel(8, 3, 2);
  matrix.drawPixel(9, 3, 2);
  matrix.drawPixel(10, 3, 2);
 
  matrix.drawPixel(1, 4, 2);
  matrix.drawPixel(2, 4, 2);
  matrix.drawPixel(3, 4, 2);
  matrix.drawPixel(4, 4, 2);
  matrix.drawPixel(9, 4, 2);
  matrix.drawPixel(10, 4, 2);
  matrix.drawPixel(11, 4, 2);
  matrix.drawPixel(12, 4, 1);
  
  matrix.drawPixel(1, 5, 2);
  matrix.drawPixel(2, 5, 2);
  matrix.drawPixel(3, 5, 2);
  matrix.drawPixel(4, 5, 2);
  matrix.drawPixel(9, 5, 2);
  matrix.drawPixel(10, 5, 2);
  matrix.drawPixel(11, 5, 2);
  matrix.drawPixel(12, 5, 1);
  
  matrix.drawPixel(1, 6, 2);
  matrix.drawPixel(2, 6, 2);
  matrix.drawPixel(11, 6, 2);
  matrix.drawPixel(12, 6, 1);
  matrix.drawPixel(13, 6, 2);
  matrix.drawPixel(14, 6, 2);
  matrix.drawPixel(15, 6, 2);
  matrix.drawPixel(16, 6, 2);
  matrix.drawPixel(19, 6, 2);
  matrix.drawPixel(20, 6, 2);
  matrix.drawPixel(21, 6, 2);
  matrix.drawPixel(22, 6, 2);
 
  matrix.drawPixel(1, 7, 2);
  matrix.drawPixel(2, 7, 2);
  matrix.drawPixel(11, 7, 2);
  matrix.drawPixel(12, 7, 1);
  matrix.drawPixel(13, 7, 2);
  matrix.drawPixel(14, 7, 2);
  matrix.drawPixel(15, 7, 2);
  matrix.drawPixel(16, 7, 2);
  matrix.drawPixel(19, 7, 2);
  matrix.drawPixel(20, 7, 2);
  matrix.drawPixel(21, 7, 2);
  matrix.drawPixel(22, 7, 2);
  
  matrix.drawPixel(1, 8, 2);
  matrix.drawPixel(2, 8, 2);
  matrix.drawPixel(13, 8, 2);
  matrix.drawPixel(14, 8, 2);
  matrix.drawPixel(15, 8, 2);
  matrix.drawPixel(16, 8, 2);
  matrix.drawPixel(19, 8, 2);
  matrix.drawPixel(20, 8, 2);
  matrix.drawPixel(21, 8, 2);
  matrix.drawPixel(22, 8, 2);
  
  matrix.drawPixel(1, 9, 2);
  matrix.drawPixel(2, 9, 2);
  matrix.drawPixel(13, 9, 2);
  matrix.drawPixel(14, 9, 2);
  matrix.drawPixel(15, 9, 2);
  matrix.drawPixel(16, 9, 2);
  matrix.drawPixel(19, 9, 2);
  matrix.drawPixel(20, 9, 2);
  matrix.drawPixel(21, 9, 2);
  matrix.drawPixel(22, 9, 2);
  
  matrix.drawPixel(1, 10, 2);
  matrix.drawPixel(2, 10, 2);
  matrix.drawPixel(3, 10, 2);
  matrix.drawPixel(4, 10, 2);
  
  matrix.drawPixel(1, 11, 2);
  matrix.drawPixel(2, 11, 2);
  matrix.drawPixel(3, 11, 2);
  matrix.drawPixel(4, 11, 2);

  matrix.drawPixel(3, 12, 2);
  matrix.drawPixel(4, 12, 2);
  matrix.drawPixel(5, 12, 2);
  matrix.drawPixel(6, 12, 2);
  matrix.drawPixel(7, 12, 2);
  matrix.drawPixel(8, 12, 2);

  matrix.drawPixel(3, 13, 2);
  matrix.drawPixel(4, 13, 2);
  matrix.drawPixel(5, 13, 2);
  matrix.drawPixel(6, 13, 2);
  matrix.drawPixel(7, 13, 2);
  matrix.drawPixel(8, 13, 2);
  
  matrix.drawPixel(5, 14, 2);
  matrix.drawPixel(6, 14, 2);
  matrix.drawPixel(7, 14, 2);
  matrix.drawPixel(8, 14, 2);
  matrix.writeScreen();
  
   delay(3000);
  
     matrix.clearScreen();

  // whew!
}

thats all the code
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 238
Posts: 24322
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Can I recommend you read about for loops?
They'll make your code shorter and easier to debug
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Belgium
Offline Offline
Full Member
***
Karma: 0
Posts: 187
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

i would make a table with the positions in it. like this:
Code:
int table2[8] = { 8,2 , 9,2 , 14,2 , 15,2 };

and then draw them with a for loop as AWOL said:

Code:
for (int i=0; i<= 7; i+=2)  {
     matrix.drawPixel(table2[i],table[i+1],2);
}
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

im not gonna lie, i have no idea how i would use them.

but im not really going to need to shorten the code unless adding the buttons i want is going to double the amount of code. (size doesnt seem to be an issue ATM)

thanks for the loop and table info though, can i get an example of what would convert into what?
if it helps the 16x24 is 6 separate 8x8 grids wired together
« Last Edit: April 21, 2012, 08:28:44 am by canibalcrab » Logged

Belgium
Offline Offline
Full Member
***
Karma: 0
Posts: 187
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

i have no time atm, but i'll take a look at the whole code this evening. to add the buttons, just make a variable (preferable int ) that saves the mode it isin atm, like this:
Code:
int dispMode = 0;
//setup here
void loop() {
   if (digitalRead(pinToReadHere) == HIGH) {
      dispMode++;
      if (dispMode>=amountOfModes) {
         dispMode=0;
      }
   }
   if (dispMode == 1) {
      //Here comes the first drawing routine (the big zero)
   }
   else if {dispMode == 2) {
      //Here comes the second drawing routine
   }
   //etc.
}
}

and this is where the handy part about the table comes in too. Instead of doing these if statement to check the value of dispMode, you could make one table with all the vars in it, and have a pointer to the place in the table. (this sounds weird maybe).

so, you've got a table with all the variables inside (like in my previous post). All the values are inside that one table (of all the routines), so you just have to keep another table that keeps an index of where to start looking for data in the first table, got it? this might be totally overruled, but i think this is a good approach and it will save space (even if you don't want to xp )
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thanks for looking at the code. i tried implementing it into my code to no avail.

im taking a good look at the arduino tutorials while waiting for your response.

thanks again.
Logged

North Queensland, Australia
Offline Offline
Edison Member
*
Karma: 53
Posts: 1785
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Check this link too

http://www.cplusplus.com/doc/tutorial/

Topics: Control Structures & Arrays will help a lot.
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

looks promising but can i use c++ in arduino straight away? or do i need to tell it im using a different code?
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 238
Posts: 24322
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You are using C++
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

man, as if i didnt oust myself as a noob enough in the first post.

heres an update though! i got buttons working!!
as soon as i get everything all wired up i might not have anymore questions!

Edit: yep totally figured it out. just need to buy real buttons to replace the wire contacts i made....

video:
https://www.facebook.com/photo.php?v=3329071737981&notif_t=like
« Last Edit: April 22, 2012, 06:09:20 pm by canibalcrab » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

instead of making a new thread....

everything works now but im having trouble making the buttons interrupt each other

i tried the blink without delay tutorial but i cant seem to figure out how to work it into my 6 button program
Logged

Pages: [1]   Go Up
Jump to: