Arduino Code too big?

I know I'm doing something that occupies too much data but I don't know what it is or how to change it. I am using 2720 bytes of the maximum 2048

/*Parking Sensor Assistant*/
#define Green 1
#define Yellow 2
#define Red 3
#define trigPin 5
#define echoPin 6
#define buzzer 7
int sound = 0;

void setup() {
  // put your setup code here, to run once:

  pinMode(Green, OUTPUT);
  pinMode(Yellow, OUTPUT);
  pinMode(Red, OUTPUT);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(buzzer, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  long timeTaken, distance;
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  timeTaken = pulseIn(echoPin, HIGH);//determine distance of wave
  distance = (timeTaken/2)/29.1;//using timeTaken calc distance of object

  /*determine corresponding LEDs to light up with respect to the distance
  of object*/

 
   if(37<=distance<61){
      digitalWrite(Green, HIGH); 
  } else{digitalWrite(Green, LOW);}
   if(26<=distance<48){
      digitalWrite(Yellow, HIGH); 
  } else{digitalWrite(Yellow, LOW);}
    if(distance<26){
      digitalWrite(Red, HIGH); 
  } else{digitalWrite(Red, LOW);}
   sound=(distance*(400/27))+(7000/9);
      /*buzzer tone*/
      if(distance>69||distance<=0){
          noTone(buzzer);}
          else{tone(buzzer, sound);}
      delay(500);
  }

Please post your complete code within </> code tags, within this code you appear to be using maybe 40 bytes of ram. Unless you mean flash memory, but then what board are you using /

No memory problems with the code you posted. Are you confusing program storage space with dynamic memory?

If you're getting that error, the code you are compiling is not the code you're posting...

You can not render C comparisons with multiple inequalities, as you can in algebra:

 if(26 <= distance < 48){

instead you have to make each comparison separate, like this:

 if(26 <= distance and distance < 48){

david_2018:
No memory problems with the code you posted. Are you confusing program storage space with dynamic memory?

Arduino: 1.6.12 (Windows 10), Board: "ATtiny25/45/85, ATtiny25, Internal 1 MHz"

Sketch uses 2,402 bytes (117%) of program storage space. Maximum is 2,048 bytes.
Global variables use 30 bytes (23%) of dynamic memory, leaving 98 bytes for local variables. Maximum is 128 bytes.
processing.app.debug.RunnerException: Sketch too big; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing it.
 at cc.arduino.Compiler.size(Compiler.java:335)
 at cc.arduino.Compiler.build(Compiler.java:159)
 at processing.app.SketchController.build(SketchController.java:641)
 at processing.app.Editor$BuildHandler.run(Editor.java:1782)
 at java.lang.Thread.run(Thread.java:745)
Sketch too big; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing it.

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

Aha, an ATtiny... explains the memory problem. If you replace all the floating point calculations with integer calculations, you should be okay. The floating point routines use a lot of program memory.

Even on an ATtiny you should be able to fit this into a 25, i think i can fit it into a 13a. If you use an active piezo instead of a passive one, you don't need tone anymore. using floating point calculation here(timeTaken/2)/29.1 sucks up the rest. You will just have to remove the fraction and modify the comparison to that result. And you should do the multiplication before the division (keeping an eye on the size of the variable) for the sake of accuracy.

Actually, there is no need to calculate 'distance' at all. Instead, craft constant expressions for distances and compare those directly with 'timeTaken'.

Question for those experienced with the attiny chips, these look like actual pin numbers, is that how to define the pins on an attiny25?

#define Green 1
#define Yellow 2
#define Red 3
#define trigPin 5
#define echoPin 6
#define buzzer 7

is that how to define the pins on an attiny25?

No, but we were going to find that out once the skecth fits into memory. The pins are referenced by their PB (0-5) but as far as i know there are some complications for PB5, being also the reset pin. If you want to use it as a normal pin there is something you can do, or it is useable as an input pin wit limited range.