Jump to content
  • 0

intwarrior

Question

I bought a Wi-Fi Shield(B) recently. I'm new to all this. I have the Wi-Fi shield sandwiched in between the Max32 & the I/O shield. This is ok right? My main concern however is that the SW1 & the BTN2 & BTN4 are always high. I used the below code for example to test it & LD{1, 5 & 7} are always high. It is the switches & buttons, not the LD's, b/c other programs that don't involve those buttons don't light them up. And these programs work perfectly fine w/ the Max32 & I/O Shield.

Did I do something wrong or is the device faulty? Thanks so much!


// set pin numbers:
const int BTN1 = 4;     // the number of the pushbutton pin
const int BTN2 = 78;    //***** Note: label on the board is for Uno32, this is MAX32, see MAX32 Reference Manual
const int BTN3 = 80;    // *** 9-26-2013: Corrected by Noe, Anita & Yanyao
const int BTN4 = 81;    // *** 9-26-2013: Corrected by Noe, Anita & Yanyao

const int ledPin =  13;      // System Operational LED
const int LD1 =  70;     //***** Note: label on the board is for Uno32, this is MAX32, see MAX32 Reference Manual
const int LD2 =  71;     //******** Reference manual is wrong! LD pins are corrected here.
const int LD3 =  72;
const int LD4 =  73;
const int LD5 =  74;
const int LD6 =  75;
const int LD7 =  76;
const int LD8 =  77;

const int SW1 = 2;
const int SW2 = 7;
const int SW3 = 8;
const int SW4 = 79;     //***** Note: label on the I/O board is 35 for uno32 only
// variables will change:
int BTN1_state = 0;         // variable for reading the pushbutton status
int BTN2_state = 0;
int BTN3_state = 0;
int BTN4_state = 0;
int SW1_state = 0;
int SW2_state = 0;
int SW3_state = 0;
int SW4_state = 0;
void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT); 
  pinMode(LD1, OUTPUT); 
  pinMode(LD2, OUTPUT);
  pinMode(LD3, OUTPUT); 
  pinMode(LD4, OUTPUT);   
  pinMode(LD5, OUTPUT); 
  pinMode(LD6, OUTPUT);
  pinMode(LD7, OUTPUT); 
  pinMode(LD8, OUTPUT);  

 
  // initialize the pushbutton pin as an input:
  pinMode(BTN1, INPUT); 
  pinMode(BTN2, INPUT); 
  pinMode(BTN3, INPUT); 
  pinMode(BTN4, INPUT); 
  // initialize switches as inputs:
   pinMode(SW1, INPUT); 
   pinMode(SW2, INPUT);
   pinMode(SW3, INPUT);
   pinMode(SW4, INPUT);
}
void loop(){
  // System Operation LED ON:
     digitalWrite(ledPin, HIGH);
     delay(50);                  // wait for 50 ms
  //----------------------------------------------  
  // read the state of the pushbutton value:
  BTN1_state = digitalRead(BTN1);
  BTN2_state = digitalRead(BTN2);
  BTN3_state = digitalRead(BTN3);
  BTN4_state = digitalRead(BTN4);

  // read switches:
  SW1_state = digitalRead(SW1);
  SW2_state = digitalRead(SW2);
  SW3_state = digitalRead(SW3);
  SW4_state = digitalRead(SW4);
 
  // Control LEDs based on buttons & Switches:
 
  if (SW1_state == HIGH) {digitalWrite(LD1, HIGH);  }
  if (SW1_state == LOW) {digitalWrite(LD1, LOW);  }
 
  if (SW2_state == HIGH) {digitalWrite(LD2, HIGH);  }
  if (SW2_state == LOW) {digitalWrite(LD2, LOW);  }
 
  if (SW3_state == HIGH) {digitalWrite(LD3, HIGH);  }
  if (SW3_state == LOW) {digitalWrite(LD3, LOW);  }
 
  if (SW4_state == HIGH) {digitalWrite(LD4, HIGH);  }
  if (SW4_state == LOW) {digitalWrite(LD4, LOW);  }
 
  if (BTN1_state == HIGH) { digitalWrite(LD5, HIGH);   }
  if (BTN1_state == LOW) { digitalWrite(LD5, LOW);   }
 
  if (BTN2_state == HIGH) { digitalWrite(LD6, HIGH);   }
  if (BTN2_state == LOW) { digitalWrite(LD6, LOW);   }
 
  if (BTN3_state == HIGH) { digitalWrite(LD7, HIGH);   }
  if (BTN3_state == LOW) { digitalWrite(LD7, LOW);   }
 
  if (BTN4_state == HIGH) { digitalWrite(LD8, HIGH);   }
  if (BTN4_state == LOW) { digitalWrite(LD8, LOW);   }
 
 
  //------------------------------------
   // System Operation LED OFF:
     digitalWrite(ledPin, LOW);
     delay(50);                  // wait for 50 ms
 
} // end loop
Link to comment
Share on other sites

1 answer to this question

Recommended Posts

Hi @intwarrior,

Looking at the schematics for the wifi and basic I/O shields here and here.  On j2 chipkit pin 2(int) and 4(sdcs) on the wifi-shield is tied to 3v3 and are active low. On j1 chipkit pins 34,9,35,36 are tied to the wifi component. Unfortunately, these conflicts between pins will effect functionality on the basic I/O and wifi shield like sw1(rd8) , btn1(rf1), btn2(rd5) on the basic I/O shield.

cheers,

Jon 

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...