Ir remote implementation problem

i have problems implementing ir sensor comnd which is the irrecv and also dosent work on the remote please i need help i get this error

sketch_apr19a:37:22: error: 'us_time' was not declared in this scope

attachInterrupt(0, us_time, RISING);

                  ^~~~~~~

C:\Users\SAM\Downloads\sketch_apr19a\sketch_apr19a.ino: In function 'void loop()':

sketch_apr19a:47:4: error: 'translateIR' was not declared in this scope

translateIR();

^~~~~~~~~~~

sketch_apr19a:48:4: error: 'unknownRemoter' was not declared in this scope

unknownRemoter();

^~~~~~~~~~~~~~

sketch_apr19a:57:5: error: 'update_time' was not declared in this scope

 update_time();

 ^~~~~~~~~~~

sketch_apr19a:77:3: error: 'img' was not declared in this scope

img();

^~~

sketch_apr19a:85:3: error: 'Display' was not declared in this scope

Display();

^~~~~~~

sketch_apr19a:96:3: error: 'Display_' was not declared in this scope

Display_();

^~~~~~~~

C:\Users\SAM\Downloads\sketch_apr19a\sketch_apr19a.ino:96:3: note: suggested alternative: 'isblank'

Display_();

^~~~~~~~

isblank

sketch_apr19a:126:3: error: 'img' was not declared in this scope

img();

^~~

sketch_apr19a:130:3: error: 'drawMinuteMarker' was not declared in this scope

drawMinuteMarker();

^~~~~~~~~~~~~~~~

sketch_apr19a:133:3: error: 'drawHourMarker' was not declared in this scope

drawHourMarker();

^~~~~~~~~~~~~~

sketch_apr19a:137:3: error: 'drawQuarterMarker' was not declared in this scope

drawQuarterMarker();

^~~~~~~~~~~~~~~~~

sketch_apr19a:141:3: error: 'drawHoursHand' was not declared in this scope

drawHoursHand();

^~~~~~~~~~~~~

sketch_apr19a:164:3: error: 'drawMinutesHand' was not declared in this scope

drawMinutesHand();

^~~~~~~~~~~~~~~

sketch_apr19a:191:3: error: 'drawSecondsHand' was not declared in this scope

drawSecondsHand();

^~~~~~~~~~~~~~~

sketch_apr19a:245:3: error: 'Clear' was not declared in this scope

Clear();

^~~~~

sketch_apr19a:265:5: error: 'update_time' was not declared in this scope

 update_time();

 ^~~~~~~~~~~

sketch_apr19a:271:1: error: a function-definition is not allowed here before '{' token

{

^

sketch_apr19a:301:3: error: a function-definition is not allowed here before '{' token

{

^

sketch_apr19a:307:3: error: a function-definition is not allowed here before '{' token

{

^

sketch_apr19a:315:3: error: a function-definition is not allowed here before '{' token

{

^

sketch_apr19a:323:3: error: a function-definition is not allowed here before '{' token

{

^

sketch_apr19a:335:3: error: a function-definition is not allowed here before '{' token

{

^

sketch_apr19a:348:3: error: a function-definition is not allowed here before '{' token

{

^

sketch_apr19a:361:3: error: a function-definition is not allowed here before '{' token

{

^

sketch_apr19a:379:3: error: a function-definition is not allowed here before '{' token

{

^

sketch_apr19a:397:3: error: a function-definition is not allowed here before '{' token

{

^

sketch_apr19a:415:1: error: a function-definition is not allowed here before '{' token

{

^

sketch_apr19a:445:1: error: a function-definition is not allowed here before '{' token

{

^

In file included from C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:30:0,

             from sketch\sketch_apr19a.ino.cpp:1:

sketch_apr19a:455:1: error: expected unqualified-id before string constant

ISR(USART_RX_vect)

^

sketch_apr19a:456:1: error: a function-definition is not allowed here before '{' token

{

^

sketch_apr19a:498:1: error: expected '}' at end of input

}

^

exit status 1

'us_time' was not declared in this scope

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.


// hobbyprojects
// 27-05-2020  Propeller_LED_Pendulum_Clock.ino
#include <IRremote.h>
char ch;
int sensorPin = 2;
unsigned int i,n,c,nc,k,d,y,bn,mp,m = 0;
float dl;
unsigned long timecurr,timeold,previousTime = 0;
int hours = 12;
int minutes = 15;
int seconds = 00;
uint16_t timer_count_A=0; 
byte number,t,a,temp,data = 0;
int val;
IRrecv irrecv(2);
decode_results results;
const PROGMEM  unsigned char data1[]={0x3e,0x22,0x22,0x3e,0x00,0x12,0x3e,0x02,0x2e,0x2a,0x2a,0x3a,0x2a,0x2a,0x2a,0x3e,0x38,0x08,0x08,0x3e,0x3a,0x2a,0x2a,0x2e,0x3e,0x2a,0x2a,0x2e,0x20,0x26,0x28,0x30,0x3e,0x2a,0x2a,0x3e,0x3a,0x2a,0x2a,0x3e,0x64,0x63,0x62,0x61,0x60,0x5F,0x5E,0x5D,0x5C,0x5B,0x5A,0x59,0x58,0x57,0x56,0x55,0x54,0x53,0x52,0x51,0X51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0x5F,0x60,0x61,0x62,0x63,0x64,0x10,0x38,0x10,0x10,0x38,0x38,0x7c,0x7F,0x7f,0x7F,0x7c,0x38,0x38,0x10,0x10,0x38,0x10,0x04,0x0e,0x1f,0x0e,0x04,0x3e,0x08,0x08,0x3e,0x00,0x00,0x1c,0x22,0x22,0x1c,0x00,0x00,0x3e,0x2a,0x2a,0x14,0x00,0x00,0x3e,0x2a,0x2a,0x14,0x00,0x20,0x10,0x0e,0x10,0x20,0x00,0x00,0x3e,0x28,0x28,0x10,0x00,0x00,0x3e,0x28,0x2c,0x12,0x00,0x00,0x1c,0x22,0x22,0x1c,0x00,0x00,0x0c,0x02,0x02,0x3c,0x00,0x00,0x3e,0x2a,0x2a,0x22,0x00,0x00,0x1c,0x22,0x22,0x22,0x00,0x00,0x20,0x20,0x3e,0x20,0x20,0x00,0x00,0x12,0x2a,0x2a,0x24};

void setup() 
{
  DDRD = 0xFA;
  DDRB = 0xFF;
  DDRC = 0x3F;
  PORTD = 0x05;
  PORTB = 0x00;      
  PORTC = 0x00;  

  if(hours > 11) 
  hours = hours - 12;

  m = 0;

   UBRR0 = 832;   // baud rate 1200bps
   UCSR0C |= (1 << UCSZ01) | (1 << UCSZ00); 
   UCSR0B |= (1 << RXEN0) | (1 << TXEN0) | (1 << RXCIE0);  


  
  attachInterrupt(0, us_time, RISING);  
   irrecv.enableIRIn(); // Start the receiver
  Serial.begin(9600);  
}

void loop() 
{
  int i=0;
   if (irrecv.decode(&results)) {
   
   translateIR();
   unknownRemoter();
      
     irrecv.resume(); // Receive the next value
    
   }   
{
    val = digitalRead(sensorPin);  
    while (val == LOW)
  {
    update_time();   
    val = digitalRead(sensorPin);
  }

  a=0; 
  k=82;
  n=0;
  nc=0;
  number = 9;
  c = 44; 
  
  while(n < 120)
  {
  if(m == 0)
  {
  mp = 15;
  bn = 0; 

  while(bn < 5)
  {
  img();
  } 

  number=hours;
  if(number == 0)
  number = 12;
  number=number/10;
  c = 24;    
  Display();

  number=hours;
  if(number == 0)
  number = 12;  
  number=number%10;    
  c = 29;  
  Display();

  c = 34;
  data = 0x0A;
  Display_();

  number=minutes;
  number=number/10;
  c = 36;    
  Display();

  number=minutes;
  number=number%10;    
  c = 41;  
  Display();

  c = 46;
  data = 0x0A;
  Display_();

  number=seconds;
  number=number/10;
  c = 48;    
  Display();

  number=seconds;
  number=number%10;    
  c = 53;  
  Display();

  mp = 61;
  bn = 0; 
  while(bn < 5)
  {
  img();
  }   
  }
  if (a==0)    
  drawMinuteMarker();
  if ((k==0) || (k==10) || (k==20) || (k==30) || (k==40) || (k==50) || (k==60) || (k==70) || (k==80) || (k==90) || (k==100) || (k==110))
  {
  drawHourMarker();
  }
  if ((k==0) || (k==30) || (k==60) || (k==90))
  {
  drawQuarterMarker();  
  }
  if((k == hours*10) || (( k == 0 ) && (hours == 0)))
  {
  drawHoursHand();
  }
  if(m == 0)
  { 
  if(k == hours*10 - 2)
  digitalWrite(5,HIGH);
  if(k == hours*10 + 2)
  digitalWrite(5,HIGH);
  if((k == 118) && (hours == 0)) 
  digitalWrite(5,HIGH); 
  }
  else
  { 
  if(k == hours*10 - 2)
  digitalWrite(9,HIGH);
  if(k == hours*10 + 2)
  digitalWrite(9,HIGH);
  if((k == 118) && (hours == 0)) 
  digitalWrite(9,HIGH); 
  }
  
  if(k == minutes*2)
  {
  drawMinutesHand();   
  }
  if(m == 0)
  {  
  if(k == minutes*2 + 2)
  digitalWrite(7,HIGH);
  if(k == minutes*2 - 2)
  digitalWrite(7,HIGH);  
  if((k == 0) && (minutes == 59))
  digitalWrite(7,HIGH);
  if((k == 118) && (minutes == 0))
  digitalWrite(7,HIGH);
  }
  else
  {
  if(k == minutes*2 + 2)
  digitalWrite(11,HIGH);
  if(k == minutes*2 - 2)
  digitalWrite(11,HIGH);  
  if((k == 0) && (minutes == 59))
  digitalWrite(11,HIGH);
  if((k == 118) && (minutes == 0))
  digitalWrite(11,HIGH);    
  }
  
  if(k == seconds*2)
{
  drawSecondsHand();
}


  if(m == 0)
  {
  if(k == seconds*2 + 2)
  digitalWrite(9,HIGH);
  if(k == seconds*2 - 2)
  digitalWrite(9,HIGH);  
  if((k == 0) && (seconds == 59))
  digitalWrite(9,HIGH);
  if((k == 118) && (seconds == 0))
  digitalWrite(9,HIGH);
  }
  else
  {
  if(k == seconds*2 + 2)
  digitalWrite(13,HIGH);
  if(k == seconds*2 - 2)
  digitalWrite(13,HIGH);  
  if((k == 0) && (seconds == 59))
  digitalWrite(13,HIGH);
  if((k == 118) && (seconds == 0))
  digitalWrite(13,HIGH);
  }      

if(m == 0)
  {
  c = (pgm_read_byte(&(data1+40)[t]));

  bn = 0;     
   
  while(bn < 17)
  {       
  if(n==c)
  {

  temp = pgm_read_byte(&(data1+80)[bn]);
    
  PORTC = temp >> 1;

  if(temp & 1)
  digitalWrite(13,HIGH);  
  else
  digitalWrite(13,LOW);     
  
  }
  bn++; 
  c++; 
  }
  }

  delayMicroseconds(dl);
  Clear();
  if ((k == 80) || (k == 81))
  {    
  }
  else
  delayMicroseconds(dl*3);

  a++;
  if(a == 2)
  a=0;
  n++;
  k++;
  if(k == 120)
  k=0;
  }

    val = digitalRead(sensorPin);  
    
    while (val == HIGH)
    {
    update_time();  
    val = digitalRead(sensorPin); 
    }    
}

  void Display()
{
  if(n==c+0)
  {
  temp = (pgm_read_byte(&(data1+number*4)[0]));
  PORTC = temp >> 1;
  }
  if(n==c+1)
  {
  temp = (pgm_read_byte(&(data1+number*4)[1]));
  PORTC = temp >> 1;
  }
  if(n==c+2)
  {
  temp = (pgm_read_byte(&(data1+number*4)[2]));
  PORTC = temp >> 1;
  }
  if(n==c+3)
  {
  temp = (pgm_read_byte(&(data1+number*4)[3]));
  PORTC = temp >> 1;
  }

  c++;
  c++;
  c++;
  c++;
  c++; 
} 

  void Display_()
  {
  if(n==c)
  PORTC = data;    
  }

  void img()
  {
  if(n==mp)
  PORTC = pgm_read_byte(&(data1+97)[bn]);
  bn++; 
  mp++; 
  }  

void Clear()
  {
    for (int i = 3; i <= 20; i++)
    {
    digitalWrite(i,LOW);
    }    
  }

  void drawMinuteMarker()
  {
    if(m == 0)
    {  
    digitalWrite(12,HIGH);
    }
    else
    {  
    digitalWrite(A5,HIGH); 
    }    
  }
  
  void drawHourMarker()
  {
    if(m == 0)
    {  
    digitalWrite(11,HIGH);
    }
    else
    {  
    digitalWrite(A4,HIGH);
    digitalWrite(A3,HIGH);    
    }  
  }

  void drawQuarterMarker()
  {
    if(m == 0)
    {  
    digitalWrite(10,HIGH);
    }
    else
    {  
    digitalWrite(A2,HIGH);
    digitalWrite(A1,HIGH);    
    }  
  }

  void drawHoursHand()
  {
    if(m == 0)
    {    
    for (int i = 3; i <= 6; i++)
    {
    digitalWrite(i,HIGH);
    }
    }
    else
    {     
    for (int i = 3; i <= 10; i++)
    {
    digitalWrite(i,HIGH);
    }
    } 
  }

  void drawMinutesHand()
  { 
    if(m == 0)
    {   
    for (int i = 3; i <= 8; i++)
    {
    digitalWrite(i,HIGH);
    }
    }
    else
    {     
    for (int i = 3; i <= 12; i++)
    {
    digitalWrite(i,HIGH);
    }
    } 
  }

  void drawSecondsHand()
  { 
    if(m == 0)
    {     
    for (int i = 3; i <= 10; i++)
    {
    digitalWrite(i,HIGH);
    }
    }
    else
    {     
    for (int i = 3; i <= 14; i++)
    {
    digitalWrite(i,HIGH);
    }
    }    
  }

void update_time()  
{
 if (millis() >= (previousTime)) 
{
   previousTime = previousTime + 25;
   t++;
   if (t == 40)
   {
   t = 0;
   seconds++;
   }   

  if(seconds == 60)
  {
  seconds = 0;
  minutes++;
  }

  if(minutes == 60)
  {
  minutes = 0;
  hours++;
  }

  if(hours > 11) 
  hours = hours - 12;

}      
}

   void us_time()
{    
  n = 0;
  timecurr = micros()-timeold;
  timeold = micros(); 
  if(m == 0)   
  dl = timecurr/1000;
  else
  dl = timecurr/650;  
} 

ISR(USART_RX_vect)
{ 
  ch=UDR0;
  if (ch == '1')
  {  
  hours--;
  if(hours < 0)
  hours = 11;
  ch = '0';
  }
  if (ch == '2')
  {  
  hours++;
  if(hours == 12)
  hours = 0;
  ch = '0';
  }
  if (ch == '3')
  {  
  minutes--;
  if(minutes < 0)
  minutes = 59;
  ch = '0';
  }  
  if (ch == '4')
  {  
  minutes++;
  if(minutes == 60)
  minutes = 0;
  ch = '0';
  } 
  if (ch == '5')
  {  
  seconds = 0;
  ch = '0';
  } 
  if (ch == '6')
  {  
  m++;
  if(m == 2)
  m = 0;
  ch = '0';
  } 
}

your curly braces in void loop() don't add up. Did you know that if you click just to the right of a curly brace, the IDE will put a little box around its match and tell you if it's next to void loop() and so on?

Also, it looks like you call two different functions that aren't in the code anywhere, so I made them up:


  void translateIR(){
    Serial.println("hi");
  }
 void unknownRemoter(){
    Serial.println("bye");
  }

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.