Skip to content

Commit

Permalink
added arduinocontrols example and version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentsijben committed Apr 9, 2024
1 parent 84aaf02 commit 1958989
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 7 deletions.
3 changes: 3 additions & 0 deletions examples/All_combined/genart_heart/genart_heart.pde
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
* This is a replica of the created instagram video for the
* Communication & Multimedia Design Generative Art Expo 2024
* by https://www.instagram.com/raoulboers/
*
* Music by Ananya Samyt
*/

import ddf.minim.*;
Expand Down Expand Up @@ -54,6 +56,7 @@ public void setup() {
.addArduino(arduino)
.addLED(11, LEDMode.PWM)
.addPushButton(8, '1', Arduino.LOW)
.setInfoPanelKey('p')
;

heart_textured = loadShape("heart_textured.obj");
Expand Down
66 changes: 66 additions & 0 deletions examples/ArduinoControls/all_controls/all_controls.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/**
* all controls
* a demo sketch for testing 3 pushbuttons, 3 potentiometers and 3 LED's.
* https://github.com/vincentsijben/bpm-timings-for-processing
*
* This example requires a connected Arduino board with:
* 3 pushbuttons at digital ports 5,6 and 7
* 3 potentiometers at ports A0, A1, A2
* 3 LEDs at digital ports 9, 10 and 11
*
*/

import bpm.library.arduinocontrols.*;
import processing.serial.*;
import cc.arduino.*;

Arduino arduino;
ArduinoControls ac;

void setup() {
size(900, 500);

println(Arduino.list());
arduino = new Arduino(this, Arduino.list()[2], 57600);
arduino.pinMode(5, Arduino.INPUT_PULLUP);
arduino.pinMode(6, Arduino.INPUT_PULLUP);
arduino.pinMode(7, Arduino.INPUT_PULLUP);
arduino.pinMode(9, Arduino.OUTPUT);
arduino.pinMode(10, Arduino.OUTPUT);
arduino.pinMode(11, Arduino.OUTPUT);

ac = new ArduinoControls(this)
.addArduino(arduino)
.addLED(9, LEDMode.PWM)
.addLED(10, LEDMode.PWM)
.addLED(11, LEDMode.PWM)
.addPushButton(5, '1', Arduino.LOW)
.addPushButton(6, '2', Arduino.LOW)
.addPushButton(7, '3', Arduino.LOW)
.addPotentiometer(0, 'q')
.addPotentiometer(1, 'w')
.addPotentiometer(2, 'e')
.showInfoPanel()
;

delay(2000);
}

void draw() {
background(50);

// use the potentiometers normalized values to control each LED brightness
ac.setLED(0, int(lerp(0, 255, ac.getPotentiometer(0))));
ac.setLED(1, int(lerp(0, 255, ac.getPotentiometer(1))));
ac.setLED(2, int(lerp(0, 255, ac.getPotentiometer(2))));

noFill();
if (ac.getPushButton(0)) fill(255, 0, 0);
if (ac.getPushButton(1)) fill(0, 255, 0);
if (ac.getPushButton(2)) fill(0, 0, 255);

//show ellipse at relative smoothed potentiometer value (prevents jumping around)
circle(lerp(0, width, ac.getPotentiometer(0, 0.1)), height/4*1, 100);
circle(lerp(0, width, ac.getPotentiometer(1, 0.1)), height/4*2, 100);
circle(lerp(0, width, ac.getPotentiometer(2, 0.1)), height/4*3, 100);
}
13 changes: 10 additions & 3 deletions examples/ArduinoControls/basics/basics.pde
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
// Import the library to your sketch
/**
* basics
* a demo sketch for using the ArduinoControls class. It uses the onboard LED (digital port 13).
* https://github.com/vincentsijben/bpm-timings-for-processing
*
* This example requires a connected Arduino board with:
* 1 LED at digital ports 13
*
*/

import bpm.library.arduinocontrols.*;

// Import the arduino and serial libraries
import processing.serial.*;
import cc.arduino.*;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/**
* controls
* smoothing
* a demo sketch showing how to use smoothed values for potentiometers. Also includes a pushbutton and an LED.
* https://github.com/vincentsijben/bpm-timings-for-processing
*
* This example requires a connected Arduino board with:
* a pushbutton at digital pin 7
* a pushbutton at digital port 7
* a potentiometer at A0
* a LED at digital port 9
*
Expand Down
4 changes: 2 additions & 2 deletions resources/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,12 @@ source.repository=https://github.com/vincentsijben/bpm-tmings-for-processing.git
# This is used to compare different versions of the same Library, and check if
# an update is available.

library.version=15
library.version=16


# The version as the user will see it.

library.prettyVersion=1.2.1
library.prettyVersion=1.2.2


# The min and max revision of Processing compatible with your Library.
Expand Down

0 comments on commit 1958989

Please sign in to comment.