KenoLeno

PerubahanAlpha

Oct 29th, 2022
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. /*
  2. Simulasi Elkadaya
  3. */
  4. #define to_triac 3
  5. #define interup 2
  6. #define potensio A0
  7. int x;
  8. void setup() {
  9. Serial.begin(9600);
  10. pinMode(to_triac, OUTPUT);
  11. pinMode(potensio, INPUT);
  12. attachInterrupt(digitalPinToInterrupt(interup),alphaa, RISING);
  13. }
  14.  
  15. void loop() {
  16. x=analogRead(potensio);
  17. x=map(x,0,1023,0,10000);
  18. Serial.println(x);
  19. }
  20.  
  21. void alphaa() {
  22. delayMicroseconds(x);
  23. digitalWrite(to_triac,HIGH);
  24. delayMicroseconds(100);
  25. digitalWrite(to_triac,LOW);
  26. }
  27.  
  28.  
Advertisement
Add Comment
Please, Sign In to add comment