Hello People,
I have an arduino code running on UNO and have some attiny 13A mcu's in hand. I want some information if i can open the arduino Sketch file(.ino) in atmel studio 7 and modify the pin configurations according to the Attiny to make it run. I am posting the Code below. I do have an Atmel ICE programmer to program attiny. I have very little knowledge about AVR C programming. If not sure of anything, please ask me as many questions as you can. Any help will be appreciated. Thanks.
Below is how the Code works.
I have an LDR which is placed on to an LCD and senses the brightness of an LCD. If the LCD shuts off, MCU is supposed to turn on a buzzer and latch on to it and should not turn off until I press the RESET button.
Actual code
int LDR = 1; //analog pin to which LDR is connected, here we set it to 0 so it means A0
int LDRValue = 0; //that’s a variable to store LDR values
int speakerPin = 6;
int light_sensitivity = 75; //This is the approx value of light surrounding your LDR
void setup()
{
Serial.begin(9600); //start the serial monitor with 9600 baud
pinMode(13, OUTPUT); //we mostly use 13 because there is already a built in yellow LED in arduino which shows output when 13 pin is enabled
pinMode(11, INPUT); // Reset Button.
pinMode(9,OUTPUT);
}
void loop()
{
digitalWrite(9,HIGH);
LDRValue = analogRead(LDR); //reads the ldr’s value through LDR
Serial.println(LDRValue); //prints the LDR values to serial monitor
delay(10); //This is the speed by which LDR sends value to arduino
if (LDRValue > light_sensitivity)
{
digitalWrite(13, LOW);
}
else
{
digitalWrite(13, HIGH);
tone(speakerPin, 500);
}
if (digitalRead(11))
{
noTone(speakerPin);
}
}