Guest User

ESP_CAPACITIVE_FUNCTION_TEST_ARDUINO

a guest
Jun 24th, 2015
1,088
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.38 KB | None | 0 0
  1. //local send_pin = 4 --GPIO2
  2. #define send_pin 4
  3. //local float_pin = 3 --GPIO0
  4. #define float_pin 3
  5.  
  6. void setup(){
  7.     Serial.begin(115200);
  8.     //gpio.mode(send_pin,gpio.OUTPUT)
  9.     pinMode(send_pin,OUTPUT);
  10.     //gpio.mode(float_pin,gpio.INT)
  11.     pinMode(float_pin,INPUT);
  12.     //counter = 0
  13.     counter = 0;
  14.     //comanda = 0
  15.     comanda = 0;
  16. }
  17. //function print_comanda()
  18. void print_comanda() {
  19.  //tmr.alarm(0, 500, 0, function()  //TODO
  20.  
  21.  //print("comanda = ", comanda)
  22.  Serial.print("comanda = ");
  23.  Serial.println(comanda);
  24.  
  25.  //comanda = 0
  26.  comanda = 0;
  27.  
  28.  //end)
  29. //end
  30. }
  31.  
  32. //function incr_comanda()
  33. void incr_comanda() {
  34.  //tmr.alarm(1, 50, 0, function() //TODO
  35.  
  36.  //if counter > 3 then
  37.  if(counter > 3){
  38.     //comanda = comanda + 1
  39.     comanda++;
  40.     //counter = 0
  41.     counter = 0;
  42.    
  43.     //tmr.stop(1)  //TODO
  44.    
  45.  //end
  46.  }
  47.  //end)
  48. //end
  49. }
  50.  
  51. //function test()
  52. void test() {
  53.  //if gpio.read(float_pin) == gpio.HIGH then
  54.  if(digitalRead(float_pin) == HIGH)
  55.     //counter = counter + 1
  56.     counter++;
  57.     //incr_comanda()
  58.     incr_comanda();
  59.     //print_comanda()
  60.     print_comanda();
  61.  //end
  62.  }
  63. //end
  64. }
  65.  
  66. void loop(){
  67. //pwm.setup(send_pin, 1000, 512)
  68. analogWrite(send_pin, 128); //I don't know if this is the right value
  69. //pwm.start(send_pin)  // Not needed
  70.  
  71. //gpio.trig(float_pin,"both",test)
  72. attachInterrupt(float_pin,test,CHANGE);
  73. }
Advertisement
Add Comment
Please, Sign In to add comment