1

I am trying to convert

this project https://maker.pro/arduino/projects/simple-fm-radio-receiver-with-arduino-uno-and-rda5807m

to 3 touch sensors TTP223.

But so far my new code don't work.

Please can you have a look at these changes?

Update:

The code goes in loop and the serial monitor show: push 3 push 4 push 2 push 3 push 4 push 2

and so on

I can also see in the oled, the 3 menu options change cyclically.

TTP223 sensor linked to pin 4 stay always with his red light on.

If I touch the sensor connected to pin 3, menu does not change (Manual tune, Volume, Auto tune).

(I have checked Touch sensors if they work alone).

|
|
//TTP223
#define Pin_DOWN 4   //  destra
#define Pin_UP 2     // sinistra
#define Pin_SET 3    // menù 
#define FIX_BAND 1


int menu;
#define MAXmenu  3
int menux;
#define MAXmenux  3

|
|
void setup() 
{
  Wire.begin();   
  //Serial.begin(9600); 
  Serial.begin(57600);

//TTP223
pinMode(Pin_DOWN,INPUT_PULLUP );
pinMode(Pin_UP,INPUT_PULLUP);
pinMode(Pin_SET,INPUT_PULLUP); 
boolean SET=digitalRead(Pin_SET);
boolean UP=digitalRead(Pin_UP);
boolean DOWN=digitalRead(Pin_DOWN);

|
|
void loop() {
  int newPos;
  unsigned long now = millis();
 // static unsigned long nextFreqTime = 0;
  static unsigned long nextRadioInfoTime = 0;
  char c;
  /*entradaV = analogRead(entrada);
   
   #if DEBUG  
      Serial.print("sensor = " );  Serial.println(entradaV);delay(50);
   #endif
   */
// Boton menu   d
/* if(entradaV>500 && entradaV<524)
   { */
//TTP223
if(digitalRead(3) == HIGH) {
    delay(150);
    Serial.println("push 3");
    menu++;
    if(menu>MAXmenu)menu=1;
    Visualizar();

    #if DEBUG 
      Serial.print("menu = " );  Serial.println(menu); 
    #endif   
    //while(1020>analogRead(entrada))delay(5);

   }
            
// Boton derecho
/* if( entradaV<50)
   { */
//TTP223
if(digitalRead(4) == HIGH) {
    Serial.println("push 4");
    menux++;
    if(menux>MAXmenux)menux=MAXmenux;
    #if DEBUG 
      Serial.print("menux = " );  Serial.println(menux);
    #endif
    switch(menu)
      {
        case 1:
          frecuencia++;
          if(frecuencia>210)frecuencia=210; 
          delay(130);
        break;  
        case 2:
           volumen++;
           if(volumen>15)volumen=15;
           // while(1020>analogRead(entrada))delay(5);
        break; 
        case 3:
           busqueda(0);
           // while(1020>analogRead(entrada))delay(5);
        break; 
        case 4:
           // LcdClear();
            tft.clearDisplay();
           // visualPI();
            delay(3000);
           // LcdClear();
            tft.clearDisplay();
            frecuenciaOld=-1;
        break; 
      }              
   }
   
// Boton izquierdo
/* if( entradaV<700 && entradaV>660)
    { */
//TTP223
if(digitalRead(2) == HIGH) {
    Serial.println("push 2");
    menux--;
    if(menux<1)menux=1; 
    #if DEBUG 
      Serial.print("menux = " );  Serial.println(menux);
    #endif   
    switch(menu)
      {
        case 1:
            frecuencia--;
            if(frecuencia<0)frecuencia=0;    
            delay(130);
        break;  
        case 2:
            volumen--;
            if(volumen<0)volumen=0;
            // while(1020>analogRead(entrada))delay(5);
        break; 
        case 3:
            busqueda(1);
            // while(1020>analogRead(entrada))delay(5);
        break; 
        case 4:
           // LcdClear();
          tft.clearDisplay();
            //tft.print(frecuencia);
            //visualPTY();
            delay(3000);
           // LcdClear();
            tft.clearDisplay();
            frecuenciaOld=-1;
        break; 
      }
    
   }
|
|
3
  • 1
    I guess you want to replace the momentary buttons in the project with touch sensors. How exactly doesn't your code work? Please provide a more detailed description. Did you try to read the touch sensors by themselves (without any other code or project part) to make sure that they work correctly?
    – chrisl
    May 10 at 14:23
  • 1
    And as the TTP223 gets configured via its jumpers, have you tried something like this to check their behavior?
    – chrisl
    May 10 at 14:25
  • I have update the post
    – massimo
    May 10 at 15:15

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.