.... so sollte es gehen.
Einlesen über ADC3
mfg GerhardCode:'=============================================================================== $regfile = "AT15DEF.DAT" 'ATtiny15L-Deklarationen $crystal = 1600000 'Quarz: 1,6 MHz intern $tiny 'nur bei Tiny15 erforderlich 'für A/D-Wandler Ddrb = &B00001110 'PB1...PB3=1: PortB-Pins auf Ausgang 'Rest Eingang 'Einstellungen zur Verwendung ADC3 'Admux = &B01100011 'Bits7+6=01: dann Aref EXTERN versorgen Admux = &B00100011 'Bits7+6=00: Aref nc, VCC=Ref 'Bit5=1: LeftAdjust, nur 8 Bit in ADCH 'Bits3...0=0000: Pin ADCx wählen 'ADC3 =011 Adcsr = &B11100010 'Bit7=1:AdcOn,Bit6=1:Start,Bit5=1:Frei 'Bits2+1+0=010: AdcClock=AvrClock/4 '............................................................................... 'A/D-Schwellwerte als Konstante Const Grenzwert_1 = 40 Const Grenzwert_2 = 50 Const Grenzwert_3 = 60 Const Grenzwert_4 = 70 Const Grenzwert_5 = 80 Const Grenzwert_6 = 90 Const Grenzwert_0 = 100 ' --- Ende Definitionen und Konstanten ----------------------------------------- '******** Beginn Hauptprogramm ************************************************* Do If Adch > Grenzwert_1 Then Portb = &B00001001 'Led_1 Bit0 High Pullup If Adch > Grenzwert_2 Then Portb = &B00000101 'Led_2 If Adch > Grenzwert_3 Then Portb = &B00001101 'Led_3 If Adch > Grenzwert_4 Then Portb = &B00000011 'Led_4 If Adch > Grenzwert_5 Then Portb = &B00001011 'Led_5 If Adch > Grenzwert_6 Then Portb = &B00000111 'Led_6 If Adch > Grenzwert_0 Then Portb = &B00000001 Waitms 5 Loop End 'end program







Zitieren

Lesezeichen