2
* This firmware simply helps calibrate values for temperature readings.
3
* It is not intended to be used as an actual flashlight.
5
* It will read the voltage, then read out the raw value as a series of
6
* blinks. It will provide up to three groups of blinks, representing the
7
* hundreds digit, the tens digit, then the ones. So, for a raw value of 183,
8
* it would blink once, pause, blink eight times, pause, then blink three times.
9
* It will then wait longer and re-read the voltage, then repeat.
11
* Attiny25/45/85 Diagram
14
* Star 4 -|2 7|- Voltage ADC
22
#define FET_7135_LAYOUT // specify an I/O pin layout
23
// Also, assign I/O pins in this file:
24
#include "tk-attiny.h"
27
* =========================================================================
28
* Settings to modify per driver
34
* =========================================================================
37
#define OWN_DELAY // Don't use stock delay functions.
38
#define USE_DELAY_S // use _delay_s()
39
#define USE_DELAY_MS // Also use _delay_ms()
42
#include <avr/pgmspace.h>
43
#include <avr/interrupt.h>
44
#include <avr/sleep.h>
46
#define THERMAL_REGULATION
48
#include "tk-voltage.h"
51
PWM_LVL = (BLINK_PWM>>2);
66
// Set PWM pin to output
67
DDRB = (1 << PWM_PIN);
69
// Set timer to do PWM for correct output pin and set prescaler timing
70
TCCR0A = 0x21; // phase corrected PWM is 0x21 for PB1, fast-PWM is 0x23
71
TCCR0B = 0x01; // pre-scaler for timer (1 => 1, 2 => 8, 3 => 64...)
73
// Turn features on or off as needed
75
ACSR |= (1<<7); //AC off
77
// blink once on receiving power
85
value = get_temperature();
90
// get an average of several readings
93
value += get_temperature();
103
while (value >= 1000) {
110
while (value >= 100) {
120
while (value >= 10) {
136
// ... and wait a bit for next time