Skip to content

Instantly share code, notes, and snippets.

/*
* This sketch is made for communicating between Arduino and Processing using Serial communication.
* Mikko Eloholma, Mehackit (CC BY-SA 4.0)
*
* 1. Connect a sensor to Arduino's analog port and print the values using Serial.
* 2. Run this program once Arduino is sending the data already.
* 3. The ellipse in the middle of the canvas should react to the sensor-data.
* 4. Change the colors of the sketch and use the data for some other purpose!
*/
// Tuodaan Processingiin Serial-kirjasto.
import processing.serial.*;
// Luodaan Serial-tyypin muuttuja "port" ja kokonaislukumuuttuja "num". port on portti, josta informaatio tulee ja
// num-muuttujaan tallennetaan Arduinon lähettämä (potentiometrin) arvo.
Serial myPort;
int num;
void setup() {
// Luodaan piirtoikkuna, jonka koko on 600 x 600
/* NodeMCU remote servo controller
* by Juho @ Mehackit.org
*/
// Servo library
#include <Servo.h>
Servo servo;
// WiFi library
#include <ESP8266WiFi.h>
@mikkoelo
mikkoelo / processing_some_random_cats
Last active September 10, 2018 11:38
Processing_some_random_cats
PImage photo;
ArrayList<String> cats = new ArrayList<String>();
void setup() {
size(500, 500);
cats.add("cat_1.jpeg"); // Replace the "cat_x.xxx" names with picture-names that you put into the program folder.
// It works best if the pictures are squares (e.g. 500 x 500) so Processing doesn't have to stretch them
cats.add("cat_2.jpg");
cats.add("cat_3.jpeg");
cats.add("cat_4.jpg");
//This processing-program generates random poems based on the words in a text-file in the program-folder.
//In this example, the text-file is called shakespeare.txt. You can add your own txt file to the program-folder and randomize words from that!
// Source for Shakespeare texts: http://shakespeare.mit.edu/.
// If questions, ask [email protected].
PFont f;
String[] lines;
String[] words;
String[] shakespeare = new String[1];
@mikkoelo
mikkoelo / gist:a9d4c95ca59737e2cd9f31e6d80ea844
Created March 14, 2018 21:12
Serialpointillism_Processing
// importataan serial-kirjasto
import processing.serial.*;
import processing.video.*;
Capture video;
// luodaan serial-muuttuja ja num, johon tallennetaan luettu arvo
Serial myPort;
int num;
int num2;
void setup()
{
//initialize serial communications at a 9600 baud rate
Serial.begin(9600);
}
void loop()
{
// read and round the value from pin 0