Advertisement
Guest User

Untitled

a guest
Jul 1st, 2018
82
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None
  1. import processing.serial.*;
  2. import cc.arduino.*;
  3.  
  4. //initialisation
  5. int buttonPin = 2;
  6. int pwmPin5 = 5;
  7. int ledPinOrange = 13;
  8. int potMeterPin = 0;
  9.  
  10. // Declaration
  11. int buttonValue = 0;
  12. int ledOrangeValue = 0;
  13. int pwmPin5Value = 0;
  14. int potMeterValue = 0;
  15. color circleColor = color(255, 0, 0);
  16.  
  17. Arduino arduino;
  18.  
  19. void arduinoSetup() {
  20. //size(800, 800);
  21.  
  22. // Prints out the available serial ports.
  23. println(Arduino.list());
  24.  
  25. /*
  26. Modify the "arduino = new Arduino(this,"?????", 57600) line below,
  27. to the number corresponding to the serial port of your Arduino board.
  28. For windows: "COM?" and for MAC "/dev/tty.usbmodem???".
  29. */
  30. arduino = new Arduino(this, "COM6", 57600);
  31.  
  32. // Set the Arduino digital pins as inputs.
  33. arduino.pinMode(buttonPin, Arduino.INPUT);
  34.  
  35. // Set the Arduino digital pins as on/off outputs.
  36. arduino.pinMode(ledPinOrange, Arduino.OUTPUT);
  37.  
  38. // PWM outputs not necesarry toe declare
  39. }
  40.  
  41. void readInputs() {
  42.  
  43. buttonValue = arduino.digitalRead(buttonPin);
  44. // println("============================== ");
  45. // println("buttonValue = " + buttonValue);
  46. }
  47.  
  48. void calculations() {
  49.  
  50. if (buttonValue == 1) {
  51. circleColor = color(0, 255, 0);
  52. } else {
  53. circleColor = color(255, 0, 0);
  54. }
  55.  
  56. ledOrangeValue = buttonValue;
  57. pwmPin5Value = potMeterValue/4;
  58. }
  59.  
  60. void writeOutputs() {
  61. //Output On/Off
  62. //println("ledOrangeValue = " + ledOrangeValue);
  63. arduino.digitalWrite(ledPinOrange, ledOrangeValue);
  64.  
  65. // PWM
  66. // Output analog values (PWM waves) to digital pins 5,6 and 9.
  67. // Note that only certain Arduino pins support analog output (PWM).
  68. // println("pwmPin5Value = " + pwmPin5Value);
  69. arduino.analogWrite(pwmPin5, pwmPin5Value);
  70. }
  71.  
  72. void drawDisplay() {
  73. //fill(circleColor);
  74. // ellipse(width/2, height/2, potMeterValue, potMeterValue);
  75. }
Advertisement
RAW Paste Data Copied
Advertisement