Setting a pin High or Low from serial input from dtmf shield

Hello, I have downloaded this sketch below, it runs perfect. My DTMF shield is connected to pins 3-7.
I would like to control output pins from the number I get from the DTMF shield. Any input would be appreciated.
Thank You

void setup() {
  pinMode(3, INPUT);
  pinMode(4, INPUT);
  pinMode(5, INPUT);
  pinMode(6, INPUT);
  pinMode(7, INPUT);

void loop() {
  uint8_t number;
  bool signal ;  
  signal = digitalRead(3);
  if(signal == HIGH)	/* If new pin pressed */
    number = ( 0x00 | (digitalRead(7)<<0) | (digitalRead(6)<<1) | (digitalRead(5)<<2) | (digitalRead(4)<<3) );
      switch (number)
        case 0x01:
        Serial.println("Pin Pressed : 1");
        case 0x02:
        Serial.println("Pin Pressed : 2");
        case 0x03:
        Serial.println("Pin Pressed : 3");
        case 0x04:
        Serial.println("Pin Pressed : 4");
        case 0x05:
        Serial.println("Pin Pressed : 5");
        case 0x06:
        Serial.println("Pin Pressed : 6");
        case 7:
        Serial.println("Pin Pressed : 7");
        case 0x08:
        Serial.println("Pin Pressed : 8");
        case 0x09:
        Serial.println("Pin Pressed : 9");
        case 0x0A:
        Serial.println("Pin Pressed : 0");
        case 0x0B:
        Serial.println("Pin Pressed : *");
        case 0x0C:
        Serial.println("Pin Pressed : #");

I do not get it.


    number = ( 0x00 | (digitalRead(7)<<0) | (digitalRead(6)<<1) | (digitalRead(5)<<2) | (digitalRead(4)<<3) );

Why waste the power of the Arduino for 1/4 second with delay(250) ? Why bother with the 0x00 term? Why bother shifting by 0?


There is a switch/case statement that looks at all of the reasonable choices on a DTMF keypad. What more than putting

digitalWrite(pinNumber, pinState) ;

in the correct place is needed?

The 250 delay keeps from getting multiple digits with one key press of the dtmf generator.

So, you don't really want to know that a key is pressed, you want to know when a key goes from unpressed to pressed (becomes pressed). There is an example that covers this. I am away from my computer or I would tell you the exact name.

Thanks vaj4088, I added "digitalWrite(pinNumber, pinState) ;" in the code and does exactly want I wanted. I may like to ad other feature soon. How this works, if 1 is pressed it turns on an output, if 2 is pressed it turns off the output, and so on.

I am glad that I could help.

Eventually, you should look at the example

**File ** | **Examples ** | 02.Digital | StateChangeDetection