Ardoise magique

Projet : réaliser une Ardoise Magique.

Ardoise magique

Monter deux potentiomètres  comme sur le schéma suivant :

ArdoiseGicma

 

Charger l’Arduino avec Firmata Standard. Et lancer ce code Processing :

import processing.serial.*;              // Firmata
import org.firmata.*;
import cc.arduino.*;

Arduino A;                              // Arduino object

int lastX;                              // Where will be stored pot values
int lastY;
int currentX;
int currentY;

void setup(){
  size(600, 600);          // Window size
  background(#000000);     // Colors
  stroke(#FFFFFF);

  noSmooth();              // We'll have nice and clear 1px lines

  A = new Arduino(this, Arduino.list()[0], 57600);  // Connect to the Arduino
  lastX = A.analogRead(0);    // First reading of the pot
  lastY = A.analogRead(1);
} 

void draw(){
   currentX = A.analogRead(0);              // Read pot values store it
   currentY = A.analogRead(1);
   stroke(#509090);                         // Draw a blue line between current and last cursor position
   line(currentX, currentY, lastX, lastY);
   stroke(#FFFFFF);                         // Draw a white pixel at current cursor's position
   point(currentX, currentY);
   point(lastX, lastY);
   lastX = currentX;      // Store current values for the next frame
   lastY = currentY;
   println(lastX, lastY); // Print it
}