Pages: 1 ... 4 5 [6]   Go Down
Author Topic: Addressing 23017/4051 using I2C Serial Interface & PROGMEM  (Read 10050 times)
0 Members and 1 Guest are viewing this topic.
Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 597
Posts: 33328
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

In place of:-
Code:
ledBits.portMode(0, 0b0000000000000000); // set all pins on chip 0 to output
Try
Code:
for(int i=0; i<16; i++)ledBits.portMode(i,OUTPUT);
Logged

SF Bay Area
Offline Offline
Edison Member
*
Karma: 11
Posts: 1244
Arduino Ninja
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

portMode is actually 16 bits wide, so the original usage is OK.

The part where you go if(PadNote == 60) pattern |= 0x00; yada yada is later followed by if(PadNote == 60) pattern &= ~0x00; in the same unbroken chain of execution so OF COURSE it will never activate a pin.
Logged

Unique RGB LED Modules and Arduino shields: http://www.macetech.com/store

New York City, NY
Offline Offline
Full Member
***
Karma: 0
Posts: 101
Arduino Rocks!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

"in the same unbroken chain of execution so" yada yada...
Quote
if(PadNote == 60) pattern |= 0x00; yada yada is later followed by if(PadNote == 60) pattern &= ~0x00; //OF COURSE it will never activate a pin
New approach.....
Quote
instead of a big bunch of if statements
Code:
if ((PadNote[i] >= 60) && (PadNote[i] <= 75)) {
    mcp.digitalWrite(PadNote[i]-60, HIGH);
}
Code:
if ((PadNote[i] >= 60) && (PadNote[i] <= 75)) {
    mcp.digitalWrite(PadNote[i]-60, LOW);
}
Quote
lights an LED number 0 to number 15 if the PadNote is between 60 and 75, so if PadNote is 65 it will light LED number 5.
« Last Edit: May 22, 2012, 09:25:01 am by Pitchoilcan » Logged

================================
http://twit.tv/floss61
Think different
Think UbuntuStudio
============================

SF Bay Area
Offline Offline
Edison Member
*
Karma: 11
Posts: 1244
Arduino Ninja
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

That new approach may actually blink an LED, but it'll be so fast you probably won't see it. You need to think about when you want to turn the LED on, when you want to turn the LED off, and why those events can't occur in the exact same function right after one another.

Overall...you need to just sit back, take a deep breath, absorb everything you've learned so far, and THINK. Slowly. Draw stuff on a piece of paper, with a pencil. Right now I see a lot of typing, rapid fire posting, instant changes to code made on poorly understood suggestions. It looks a lot like letting a balloon go in a small room. It bounces off all the walls and makes a lot of noise, but nothing much happens.

And remember...if someone comes in here and just solves your entire problem, top to bottom, that means they don't like you. In this forum we usually try to point people in the right direction, so they can pick up the skillset to solve other problems.
« Last Edit: May 25, 2012, 01:21:06 am by macegr » Logged

Unique RGB LED Modules and Arduino shields: http://www.macetech.com/store

Pages: 1 ... 4 5 [6]   Go Up
Jump to: