Advertisement
Guest User

sketch

a guest
Jul 20th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. int led = 10;
  2. float frequency = 100;
  3. float timeDelay;
  4.  
  5.  
  6. void setup(){
  7. Serial.begin(9600);
  8. pinMode(led, OUTPUT);
  9.  
  10.  
  11. }
  12.  
  13. void loop(){
  14. frequency = Serial.read();
  15. int frequency;
  16. map(frequency, 1, 100, 100, 1000);
  17. Frequency(frequency);
  18. timeDelay = ((1 / frequency) * 500)*1000;
  19. }
  20. void Frequency(float frequency){
  21. digitalWrite(led, HIGH);
  22. delayMicroseconds((int) timeDelay);
  23. digitalWrite(led, LOW);
  24. delayMicroseconds((int) timeDelay);
  25.  
  26.  
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement