mc_workshop

Frequency Duty

Feb 7th, 2019
17
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Leggiamo lo stato digitale del pin 3 sul serial monitor, la frequenza e il Duty cycle
  2. //This example code is in the public domain.
  3. //by Marco C.
  4. int digitalValue = 0;
  5. int led = 3;
  6. float j = 250;
  7. float a;
  8. float b;
  9. void setup() {
  10.   Serial.begin(9600);
  11.   pinMode(led, OUTPUT);
  12. }
  13. void loop() {
  14.   Serial.print ("Cycle = ");
  15.   b = (j * 2 / 1000);
  16.   Serial.print (b);
  17.   Serial.println (" s");
  18.   Serial.print ("Frequenza = ");
  19.   a = 1 / (j * 2 / 1000);
  20.   Serial.print (a);
  21.   Serial.println (" Hz");
  22.   digitalValue = digitalRead(digitalValue);
  23.   digitalWrite (led, HIGH);
  24.   Serial.print ("stato pin 3 = ");
  25.   Serial.println(digitalValue);
  26.   digitalValue = 0;
  27.   delay (j);
  28.   {
  29.     digitalWrite (led, LOW);
  30.     Serial.print ("stato pin 3 = ");
  31.     Serial.println(digitalValue);
  32.     digitalValue = 0;
  33.     delay (j);
  34.   }
  35. }
RAW Paste Data