elektronik:mini-programme-fuer-attiny13

Mini-Programme für ATtiny13

  1. 'ATtiny13 driving LEDs
  2. $regfile = "attiny13.dat"
  3. $crystal = 1200000
  4. $hwstack = 8
  5. $swstack = 4
  6. $framesize = 4
  7. Config Portb = Output
  8.  
  9. Do
  10. Portb.3 = 1
  11. Toggle Portb.4
  12. Waitms 500
  13. Loop
  14.  
  15. End
  1. 'Timer 60 s
  2. $regfile = "attiny13.dat"
  3. $crystal = 1200000
  4. $hwstack = 8
  5. $swstack = 4
  6. $framesize = 4
  7.  
  8. Config Portb.4 = Output
  9. Portb.3 = 1 'Pullup
  10.  
  11. Do
  12. Do
  13. Loop Until Pinb.3 = 0
  14. Portb.4 = 1
  15. Waitms 60000
  16. Portb.4 = 0
  17. Loop
  18.  
  19. End
  1. 'LED soft flasher
  2. $regfile = "attiny13.dat"
  3. $crystal = 1200000
  4. $hwstack = 8
  5. $swstack = 4
  6. $framesize = 4
  7. Dim I As Byte
  8. Dim D As Integer
  9.  
  10. Config Portb = Output
  11. Config Timer0 = Pwm , Prescale = 1 , Compare A Pwm = Clear Down
  12.  
  13. Do
  14. For I = 40 To 215
  15. If I < 128 Then
  16. D = I
  17. D = D * D
  18. End If
  19. If I > 127 Then
  20. D = 255 - I
  21. D = D * D
  22. End If
  23. D = D / 64
  24. Pwm0a = D
  25. Waitms 60
  26. Next I
  27. Waitms 800
  28. Loop
  29. End
  1. 'Dämmerungsschalter
  2. $regfile = "attiny13.dat"
  3. $crystal = 1200000
  4. $hwstack = 8
  5. $swstack = 4
  6. $framesize = 4
  7.  
  8. Dim U As Word
  9. Config Adc = Single , Prescaler = Auto
  10. Start Adc
  11. Config Portb = 1 'Output B.0
  12.  
  13. Do
  14. U = Getadc(3)
  15. If U < 400 Then Portb.0 = 0
  16. If U > 600 Then Portb.0 = 1
  17. Waitms 1000
  18. Loop
  19. End
  1. 'Dreiphasen-Blinker 1500ms, 0,67 Hz
  2. $regfile = "attiny13.dat"
  3. $crystal = 1200000
  4. $hwstack = 8
  5. $swstack = 4
  6. $framesize = 4
  7. Config Portb = Output
  8.  
  9. Do
  10. Portb.0 = 1
  11. Waitms 250
  12. Portb.3 = 0
  13. Waitms 250
  14. Portb.4 = 1
  15. Waitms 250
  16. Portb.0 = 0
  17. Waitms 250
  18. Portb.3 = 1
  19. Waitms 250
  20. Portb.4 = 0
  21. Waitms 250
  22. Loop
  23. End
  • elektronik/mini-programme-fuer-attiny13.txt
  • Zuletzt geändert: 10.08.2024 10:45
  • von Martin Fitzel