OK. This is from pins_arduino.h under the tiny14 subdirectory:
// ATMEL ATTINY84 / ARDUINO
// VCC 1| |14 GND
// (D 10) PB0 2| |13 AREF (D 0)
// (D 9) PB1 3| |12 PA1 (D 1)
// PB3 4| |11 PA2 (D 2)
// PWM INT0 (D 8) PB2 5| |10 PA3 (D 3)
// PWM (D 7) PA7 6| |9 PA4 (D 4)
// PWM (D 6) PA6 7| |8 PA5 (D 5) PWM
The D numbers are the arduino conceptual digital pin numbers, so physical pin 11 on the chip is D2 for example
So, based on your last:
pin 13 - Photoresistor
pin 10 - Piezo
pin 11 - Led
your code should look like
#define PHOTO 0 // Physical pin 13 = tiny24 pin 0
#define PIEZO 3 // see above
#define LED 2 // same
// but you really should do this BEFORE calling any pin function e.g. analogRead!!!
The main problem you have though is your analogue writes. analogWrite uses PWM functionality on the pin. From the arduino docs:"On most Arduino boards (those with the ATmega168 or ATmega328), this function works on pins 3, 5, 6, 9, 10, and 11. On the Arduino Mega, it works on pins 2 - 13 and 44 - 46. Older Arduino boards with an ATmega8 only support analogWrite() on pins 9, 10, and 11. "
Those datasheets will show which pins have PWM functionality. On the tiny24 (see above) its chip pins 5,6,7,8 ie digital pins 5,6,7,8 (altho confusingly not in the same order!)
So, if you have to pulse PIEZO and LED, they need to be on one of those pins. On the UNO through what a poster on here calls "dumb luck"
10 and 11 support PWM so your sketch works (though you were lucky that calling analogRead before setting the pinmode also happened to work...the chip boots up with pins as inputs!)
#define PIEZO 5
#define LED 6
should sort that. Next we go back to the doc for analogWrite:
"Parameterspin: the pin to write to.
value: the duty cycle: between 0 (always off) and 255 (always on).
analogWrite(2, 1200); // turn the LED on (HIGH is the voltage level)
analogWrite(3, 1000); // turn the PIEZZO on (HIGH is the voltage level)
I'm not sure why you chose those values, and I dont want to go into 2s-complements maths on 8-bit values, but that code just aint going to do what you think it does. E.g. 1200 is 0x4B0 since you are stuffing into 8 bits, you lose the 4, giving 0xB0 which is 176 if its treated as unsigned, or -80 if its a signed value. Neither of them are close to what you thought you meant!
176/255 = 69% full brightnes (or squeak volume) so (luckily) your dodgy code will actually cause what LOOKS like a flash and a squeak. If all you want to do is turn the LED on or off, use digitalWrite (also consider the tone library for squeaking the buzzer)
To make your code clean, you need to map your value to 0-255 and also say:
for portability and ease of modification / rewiring...all you do if you move a wire is change the #define and the rest of the code "just works" without search and replace of all "2," for e.g. "11," which can change of a lot of wrong stuff accidentally if you arent careful!
A final note, UPPERCASE is usually used for such constants (just a style thing) and analog pins have special names in the pins_arduin.h file, e.g. analog pin 0 is A0.
Using A0 instead of 0 makes your code portable, ie on a UNO, A0 will be mapped to the correct pin for you, and its one less thing to change. if the framework had similar definitions for e.g. PWM pins such as PWM1, PWM2 and digital pins like DIGITAL1, DIGITAL2 etc, we wouldn't be having this conversation at all, as it just would have worked on any variant if you had said:
#define PIEZO PWM1
#define LED DIGITAL1
#define PHOTO A0
.and put the wires in the right holes (aprt from the 1200 vs 255 discussion of course!)
Hope this helps