0% found this document useful (0 votes)
79 views4 pages

Attiny Projects: Breathing Led

This document contains descriptions of three ATtiny projects: 1) A breathing LED project that uses the analogWrite function to gradually increase and decrease the brightness of an LED. 2) An LED controlled by an infrared sensor, such that the LED turns on for 1 second when the sensor detects IR light. 3) An updated version of a bike lighting project that uses an ATtiny microcontroller instead of an Arduino to control LEDs and an ultrasonic sensor, demonstrating how ATtinys can accomplish the same tasks as Arduinos.

Uploaded by

leontti
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
79 views4 pages

Attiny Projects: Breathing Led

This document contains descriptions of three ATtiny projects: 1) A breathing LED project that uses the analogWrite function to gradually increase and decrease the brightness of an LED. 2) An LED controlled by an infrared sensor, such that the LED turns on for 1 second when the sensor detects IR light. 3) An updated version of a bike lighting project that uses an ATtiny microcontroller instead of an Arduino to control LEDs and an ultrasonic sensor, demonstrating how ATtinys can accomplish the same tasks as Arduinos.

Uploaded by

leontti
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

ATtinyProjects

BreathingLED
ThisisanexampleofhowtousetheanalogWritefunctiononanATtinytocontrolthe
brightnessofanLED.ThesketchisaslightlymodifiedversionoftheexampleArduino
FadingsketchthatcanbefoundunderExamples>Analog>Fading.Itcausestheledto
increaseinbrightnessuntilitisallthewayonandthenitdiminishesinbrightness.
Hereisthesketch:
int ledPin = 4; // LED connected to digital pin 9
void setup() {
// nothing happens in setup
}
void loop() {
// fade in from min to max in increments of 5 points:
for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=2) {
// sets the value (range from 0 to 255):
analogWrite(ledPin, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
// fade out from max to min in increments of 5 points:
for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=2) {
// sets the value (range from 0 to 255):
analogWrite(ledPin, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
}

LEDControlledbyInfraredSensor
HereisanexampleofusingthebrokenoutsensorontheChipperBoard.Wehave
anIRReceiverDiodeconnectedtothesensorport,5VandGNDontheChipper
Board.WhenevertheIRReceiverDiodesenseIRlight(emittedbyTVremotes)it
sendsasignaltotheATtiny85whichturntheLEDonfor1secondandthenturnsit
off.Hereisthesketch:
int led = 4;
int ir = 3;
int sensor_value = 0;
void setup()
{
pinMode(ir,INPUT);
pinMode(led,OUTPUT);
}
void loop() {
sensor_value = digitalRead(ir);
if (sensor_value == LOW){
digitalWrite(led,HIGH);

delay(1000);
}
else{
digitalWrite(led,LOW);
}
}

BrightBikev2
ThisisanexampleofhowanATtinycanbejustaseffectiveasanArduino.Bright
Bikev1wasaprojectImadeusinga$30ArduinoUnowhichcontrolled16ledsand
oneultrasonicsensor.Thissameprojectcouldhavebeendonewitha$2ATtiny85by
multiplexingandconvertingtheresetpintoanI/Opin.IaddedafewfeaturestoBright
Bikev2soIneededanATtiny84,butyoucanseethedifferenceinqualityandhow
anATtinycanaccomplisheverythingthatanArduinocando.

You might also like