element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum Help with LED 8x8 matrix and Arduino Uno
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 1 reply
  • Subscribers 391 subscribers
  • Views 260 views
  • Users 0 members are here
  • stepper_motor
  • matrix
  • led
  • arduino
Related

Help with LED 8x8 matrix and Arduino Uno

Former Member
Former Member over 12 years ago

For a project I am using Arduino Uno to power and control two stepper motors, two buttons and an LED matrix to form a "vendin machine", I have figured out the coding to use the two buttons to power the two separate motors repsectively, check file "Code for stepper motor controled by button"..

 

However I was wondering how to program the LED matrix to show a certain pattern when a button is pushed. I know how to program the LED matrix to show a pattern consistently when the arduino is turned on forever, but I do not know how to program different patterns to show at different times, ie when a button is pushed or to show one pattern for 5 seconds and then another patterns 5 seconds latter. Any help will be greatly appreciated file "matrixface" shows how I have used the LED matrix before.

 

Code for stepper motor controled by button

 

int black=10;
int brown=8;
int orange=7;
int yellow=9;
int motor1=11;
int motor2=12;
int button1=1;
int button2=2;
int delayPeriod=20;
int n;

void setup()
{
  pinMode(orange,OUTPUT);
  pinMode(black,OUTPUT);
  pinMode(yellow,OUTPUT);
  pinMode(brown,OUTPUT);
  pinMode(motor1,OUTPUT);
  pinMode(motor2,OUTPUT);
  pinMode(button1,INPUT);
  pinMode(button2,INPUT);
  digitalWrite(orange,LOW);
  digitalWrite(black,LOW);
  digitalWrite(yellow,LOW);
  digitalWrite(brown,LOW);
  digitalWrite(motor1,LOW);
  digitalWrite(motor2,LOW);
}

void loop()
{
  int but1 = digitalRead(button1);
  if (but1 == HIGH)
 
  {
    digitalWrite(motor1,HIGH);
    digitalWrite(motor2,LOW);
   
    for (int n=0;n<6;n++)
    {
      digitalWrite(black,LOW);
  digitalWrite(brown,HIGH);
  digitalWrite(orange,HIGH);
  digitalWrite(yellow,LOW);
  delay(delayPeriod);
 
  digitalWrite(black,LOW);
  digitalWrite(brown,HIGH);
  digitalWrite(orange,LOW);
  digitalWrite(yellow,HIGH);
  delay(delayPeriod);
 
  digitalWrite(black,HIGH);
  digitalWrite(brown,LOW);
  digitalWrite(orange,LOW);
  digitalWrite(yellow,HIGH);
  delay(delayPeriod);
 
  digitalWrite(black,HIGH);
  digitalWrite(brown,LOW);
  digitalWrite(orange,HIGH);
  digitalWrite(yellow,LOW);
  delay(delayPeriod);
}
delay(1000);
}
int but2 = digitalRead(button2);
  if (but2 == HIGH)
 
  {
    digitalWrite(motor1,LOW);
    digitalWrite(motor2,HIGH);
   
    for (int n=0;n<6;n++)
    {
      digitalWrite(black,LOW);
  digitalWrite(brown,HIGH);
  digitalWrite(orange,HIGH);
  digitalWrite(yellow,LOW);
  delay(delayPeriod);
 
  digitalWrite(black,LOW);
  digitalWrite(brown,HIGH);
  digitalWrite(orange,LOW);
  digitalWrite(yellow,HIGH);
  delay(delayPeriod);
 
  digitalWrite(black,HIGH);
  digitalWrite(brown,LOW);
  digitalWrite(orange,LOW);
  digitalWrite(yellow,HIGH);
  delay(delayPeriod);
 
  digitalWrite(black,HIGH);
  digitalWrite(brown,LOW);
  digitalWrite(orange,HIGH);
  digitalWrite(yellow,LOW);
  delay(delayPeriod);
}
delay(1000);
}
}

 

Code for LED matrix repeating

int R0=2;

int R1=3;

int R2=4;

int R3=5;

int R4=6;

int R5=7;

int R6=8;

int R7=9;

int CLOCK=10;

int CLOCK_INHIBT=11;

int RESET=12;

byte rowPin[]={R0,R1,R2,R3,R4,R5,R6,R7};

boolean pinState;

byte patternRow[8];

void setup()

{

  pinMode(R0,OUTPUT);

  pinMode(R1,OUTPUT);

  pinMode(R2, OUTPUT);

  pinMode(R3, OUTPUT);

  pinMode(R4, OUTPUT);

  pinMode(R5, OUTPUT);

  pinMode(R6, OUTPUT);

  pinMode(R7, OUTPUT);

  pinMode(CLOCK, OUTPUT);

  pinMode(CLOCK_INHIBT, OUTPUT);

  pinMode(RESET, OUTPUT);

  digitalWrite(CLOCK, LOW);

  digitalWrite(CLOCK_INHIBT, LOW);

  digitalWrite(RESET, LOW);

 

  patternRow[0]=B11111111;

  patternRow[1]=B10000001;

  patternRow[2]=B10101101;

  patternRow[3]=B10010101;

  patternRow[4]=B10010101;

  patternRow[5]=B10101101;

  patternRow[6]=B10000001;

  patternRow[7]=B11111111;

}

void loop()

{

  digitalWrite(RESET, HIGH);

  delayMicroseconds(1000);

  digitalWrite(RESET,LOW);

  for (int i=0;i<8;i++)

  {

    digitalWrite(CLOCK,HIGH);

  for (int n=0;n<8;n++)

{

if (patternRow[i] & (1<<n))

{

  pinState=HIGH;

}

else

{

  pinState=LOW;

}

digitalWrite(rowPin[n],pinState);

}

for (int n=0;n<8;n++)

{

  digitalWrite(rowPin[n], LOW);

}

digitalWrite(CLOCK, LOW);

  }

}

  • Sign in to reply
  • Cancel
Parents
  • volly
    0 volly over 9 years ago

    Hi Ainsley (aka) ainsforce,

     

    I cannot believe that this topic has not been addressed nor answered after having been viewed more than 700 times.

    I also cannot believe that since Mar 2013 not a single reply at all.

     

    Firstly. Do you still need assistance with this problem or have you made another plan in the 3 years plus that you've been

    waiting for any headway?

     

    Please let me know.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • volly
    0 volly over 9 years ago

    Hi Ainsley (aka) ainsforce,

     

    I cannot believe that this topic has not been addressed nor answered after having been viewed more than 700 times.

    I also cannot believe that since Mar 2013 not a single reply at all.

     

    Firstly. Do you still need assistance with this problem or have you made another plan in the 3 years plus that you've been

    waiting for any headway?

     

    Please let me know.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube