User Tools

Site Tools


projekt:rcbil

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
projekt:rcbil [2019/01/24 00:55]
magiskaroyken kommentar riktning
projekt:rcbil [2019/01/27 19:32] (current)
magiskaroyken explicit på att det är "_pin" inte värdet ; pinläge = utgång
Line 55: Line 55:
   int speed; // 0 .. 255   int speed; // 0 .. 255
   Serial.begin(9600);​   Serial.begin(9600);​
-  ​powertrain_pwm ​ = 9; +  ​// 
-  ​steering_pwm ​   = 5; +  powertrain_pwm_pin ​ = 9; 
-  powertrain_in-= 2; +  ​steering_pwm_pin ​   = 5; 
-  powertrain_in-= 3; +  powertrain_in-a_pin = 2; 
-  // setPwmFrequency(powertrain_pwm,    8); // 3906 Hz +  powertrain_in-b_pin = 3; 
-  setPwmFrequency(steering_pwm,   ​1024);​ // 61 Hz +  // 
-  digitalWrite(powertrain_in-a, HIGH ); // Medurs (clockwise) +  pinMode(steering_pwm_pin, ​   OUTPUT); 
-  digitalWrite(powertrain_in-b, LOW );+  pinMode(powertrain_pwm_pin, ​ OUTPUT); 
 +  pinMode(powertrain_in-a_pin,​ OUTPUT); 
 +  pinMode(powertrain_in-b_pin,​ OUTPUT); 
 +  // 
 +  // setPwmFrequency(powertrain_pwm_pin,    8); // 3906 Hz 
 +  setPwmFrequency(steering_pwm_pin,   ​1024);​ // 61 Hz 
 +  digitalWrite(powertrain_in-a_pin, HIGH ); // Medurs (clockwise) 
 +  digitalWrite(powertrain_in-b_pin, LOW );
   for(;;){   for(;;){
     // 012345678901     // 012345678901
Line 74: Line 81:
       speed = atoi(cmd+4);​       speed = atoi(cmd+4);​
       angle = atoi(cmd+8);​       angle = atoi(cmd+8);​
-      AnalogWrite(powertrain_pwm, speed) +      AnalogWrite(powertrain_pwm_pin, speed) 
-      AnalogWrite(steering_pwm,   ​angle) // XX+      AnalogWrite(steering_pwm_pin,   ​angle) // XX
       }       }
     }     }
projekt/rcbil.txt · Last modified: 2019/01/27 19:32 by magiskaroyken