Gast
#3834177
Guten Tag. Ich habe folgendes Problem: Ich möchte einen Servomotor(SG90) mit einem Atmega 8 ansteuern. Der Atmega 8 bekommt von mir 8 Eingänge wo ich die Einzelnen Winkel einstellen möchte. Mein Code: $regfile = "m8def.dat" $crystal = 8000000 Config Servos = 1 , Servo1 = Portc.5 , Reload = 9 Config Portc.5 = Output Config Portc.4 = Input Config Portc.3 = Input Config Portc.2 = Input Config Portc.1 = Input Config Portc.0 = Input Config Portb.5 = Input Config Portb.4 = Input Config Portd.0 = Input Enable Interrupts 'Pullups Pinc.4 = 0 Portc.4 = 0 Portc.3 = 0 Portc.2 = 0 Portc.1 = 0 Portc.0 = 0 Portb.5 = 0 Portb.4 = 0 Portd.0 = 0 Dim Pos As Word Do If Pinc.3 = 1 Then Pos = 65 If Pinc.2 = 1 Then Pos = 80 If Pinc.1 = 1 Then Pos = 95 If Pinc.0 = 1 Then Pos = 110 If Pinc.5 = 1 Then Pos = 125 If Pinc.4 = 1 Then Pos = 140 Servo(1) = Pos Waitms 100 Loop Die Eingänge werden nur einzeln auf high gesetzt, niemals 2 zusammen. Das Problem, der Servo macht absolut was er will. Wo liegt mein Denkfehler?