Go Down

Topic: Addressing 23017/4051 using I2C Serial Interface & PROGMEM (Read 11 times) previous topic - next topic

marco_c

Pointers and integers are two different things which is why you are stopped form doing that. It has no meaning, like comparing the address of a house to the house itself.

What are you trying to do?
Arduino libraries http://arduinocode.codeplex.com
Parola hardware & library http://parola.codeplex.com

Pitchoilcan

#41
May 12, 2012, 08:10 am Last Edit: May 20, 2012, 04:19 pm by Pitchoilcan Reason: 1
//Table 1-2  (0)
if(PadNote == 60) ledBits |= 0x01;
if(PadNote == 61) ledBits |= 0x02;
if(PadNote == 62) ledBits |= 0x03;
if(PadNote == 63) ledBits |= 0x04;
if(PadNote == 64) ledBits |= 0x05;

              // the same goes for turning the LED off:-

if(PadNote == 60) ledBits &= ~0x01;
if(PadNote == 61) ledBits &= ~0x02;
if(PadNote == 62) ledBits &= ~0x03;
if(PadNote == 63) ledBits &= ~0x04;
if(PadNote == 64) ledBits &= ~0x05;
Quote
In mathematics and computer science, hexadecimal (also base 16, or hex) is a positional numeral system with a radix, or base, of 16. It uses sixteen distinct symbols, most often the symbols 0-9 to represent values zero to nine, and A,?B,?C,?D,?E,?F (or alternatively a-f) to represent values ten to fifteen. For example, the hexadecimal number 2AF3 is equal, in decimal, to (2?×?163) + (10?×?162) + (15?×?161) + (3?×?160), or 10,995.
Each hexadecimal digit represents four binary digits (bits), and the primary use of hexadecimal notation is a human-friendly representation of binary-coded values in computing and digital electronics. One hexadecimal digit represents a nibble, which is half of an octet (8 bits). For example, byte values can range from 0 to 255 (decimal), but may be more conveniently represented as two hexadecimal digits in the range 00 to FF. Hexadecimal is also commonly used to represent computer memory addresses.
OK back to my scrapbook
Quote
16 (hexadecimal)      0x7B    leading "0x"     characters 0-9, A-F, a-f valid  
================================
http://twit.tv/floss61
Think different
Think UbuntuStudio
============================

marco_c

#42
May 12, 2012, 08:39 am Last Edit: May 12, 2012, 09:30 am by marco_c Reason: 1
padNote is an array of characters (or bytes, probably)
Code: [Select]

unsigned char PadNote[48] = {35,36,37,38,39,40,41,42,


to access one of the values of padNote you need to reference it using an array index, shown as i in the code below

Code: [Select]

if (padNote[i] == 99) ledPin |=  0x1;


Just using padNote on it's own, in C++, tells the compiler you are using the address of the array. That is an advanced topic for you to learn later.
Arduino libraries http://arduinocode.codeplex.com
Parola hardware & library http://parola.codeplex.com

Pitchoilcan

void readSensors(int analogPin){
   //This for loop is used to scroll through and store the 16 inputs on the FIRST multiplexer
 for (int i=0; i<16; i++){
   digitalWrite(CONTROL0, (i&15)>>3);
   digitalWrite(CONTROL1, (i&7)>>2);  
   digitalWrite(CONTROL2, (i&3)>>1);  
   digitalWrite(CONTROL3, (i&1));    

   //Read and store the input value at a location in the array
   if(analogPin==0){
     mux0array = analogRead(analogPin);
   }
   else if(analogPin==1){
     mux1array = analogRead(analogPin);
   }
   else if(analogPin==2){
     mux2array = analogRead(analogPin);
   }
   //Table 1-2  (0)
if(PadNote == 60) ledBits |= 0x01;
if(PadNote == 61) ledBits |= 0x02;
if(PadNote == 62) ledBits |= 0x03;
if(PadNote == 63) ledBits |= 0x04;
if(PadNote == 64) ledBits |= 0x05;

if(PadNote == 65) ledBits |= 0x06;
if(PadNote == 66) ledBits |= 0x07;
if(PadNote == 67) ledBits |= 0x08;
if(PadNote == 68) ledBits |= 0x09;
if(PadNote == 69) ledBits |= 0x0A;

if(PadNote == 70) ledBits |= 0x0B;
if(PadNote == 71) ledBits |= 0x0C;
////if(PadNote == 72) ledBits |= 0x0D;
////if(PadNote == 73) ledBits |= 0x0E;
////if(PadNote == 74) ledBits |= 0x0F;

              // the same goes for turning the LED off:-

if(PadNote == 60) ledBits &= ~0x01;
if(PadNote == 61) ledBits &= ~0x02;
if(PadNote == 62) ledBits &= ~0x03;
if(PadNote == 63) ledBits &= ~0x04;
if(PadNote == 64) ledBits &= ~0x05;

if(PadNote == 65) ledBits &= ~0x06;
if(PadNote == 66) ledBits &= ~0x07;
if(PadNote == 67) ledBits &= ~0x08;
if(PadNote == 68) ledBits &= ~0x09;
if(PadNote == 69) ledBits &= ~0x0A;

if(PadNote == 70) ledBits &= ~0x0B;
if(PadNote == 71) ledBits &= ~0x0C;
////if(PadNote == 72) ledBits &= ~0x0D;
////if(PadNote == 73) ledBits &= ~0x0E;
////if(PadNote == 74) ledBits &= ~0x0F;
 }
}
================================
http://twit.tv/floss61
Think different
Think UbuntuStudio
============================

Pitchoilcan

#44
May 12, 2012, 10:07 am Last Edit: May 12, 2012, 10:38 pm by Pitchoilcan Reason: 1
added
Code: [Select]
#include <Centipede.h>
#include <Wire.h>

Centipede ledBits; // create  object

 ledBits.initialize(); // set all registers to default

 ledBits.portMode(0, 0b0000000000000000); // set all pins on chip 0 to output

Not I get
twelve of these :
Quote
no match for 'operator |=' in 'ledBits |=1'  

and
twelve of these :
Quote
no match for 'operator &=' in 'ledBits &= -0x0000000002'  

How do I resolve this ?
================================
http://twit.tv/floss61
Think different
Think UbuntuStudio
============================

Go Up