# 20221006 # arduino analogread ``` void setup() { Serial.begin(9600); } void loop() { Serial.println(analogRead(A1)); delay(100); } ``` # line mouseX background ``` void setup() { size(400, 400); } void draw() { if (mouseX > 100) { background(255, 0, 0); } else { background(255); } line(0, 0, mouseX, mouseY); line(0, mouseY, width, mouseY); line(mouseX, 0, mouseX, height); println(mouseX); text(mouseX, 100, 100); } ``` # ellips ``` void setup() { size(550, 550); } int val; void draw() { background(255); val = (int)random(1023); fill(val/4); ellipse(width/2, height/2, val/2, val/2); } ``` # arduino > processing > ellipse ``` import processing.serial.*; Serial myPort; int val; void setup() { size(500, 500); String portName = "COM4"; myPort = new Serial(this, portName, 9600); } void draw() { background(255); if ( myPort.available() > 0) { String rx = myPort.readString(); if (rx != null) { val = parseInt(trim(rx)); println(val); } } ellipse(width/2, height/2, val/2, val/2); } ```