23 Ιουνίου 2020
18 Απριλίου 2018
7 Οκτωβρίου 2015
Golan Levin – osoi asxoliste me ixo i programatismo genika dite to
17 Νοεμβρίου 2014
arduino14
Serial.begin(9600);
}
void loop() {
Serial.write(analogRead(A0)/4);
delay(1);
}
import processing.serial.*;
Serial myPort;
PImage logo;
int bgcolor = 0;
void setup() {
colorMode(HSB, 255);
logo = loadImage(“http://arduino.cc/logo.png”);
size(logo.width, logo.height);
println(“Available serial ports:”);
println(Serial.list());
myPort = new Serial(this, Serial.list()[5], 9600);
}
void draw() {
if(myPort.available() > 0) {
bgcolor = myPort.read();
println(bgcolor);
}
background(bgcolor, 255, 255);
image(logo, 0, 0);
}
Arduino13-feely Lamp
CapacitiveSensor capSensor = CapacitiveSensor(4,2);
int threshold = 1000;
const int ledPin = 12;
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
}
void loop() {
long sensorValue = capSensor.capacitiveSensor(30);
Serial.println(sensorValue);
if(sensorValue > threshold) {
digitalWrite(ledPin, HIGH);
}
else {
digitalWrite(ledPin, LOW);
}
delay(10);
}
ARDUINO12-
Servo servo9;
const int piezo = A0;
const int switchPin = 2;
const int yellowLed = 3;
const int greenLed = 4;
const int redLed = 5;
int knockVal;
int switchVal;
const int quietKnock = 10;
const int loudKnock = 100;
boolean locked = false;
int numberOfKnocks = 0;
void setup() {
servo9.attach(9);
pinMode(yellowLed, OUTPUT);
pinMode(greenLed, OUTPUT);
pinMode(redLed, OUTPUT);
pinMode(switchPin, INPUT);
Serial.begin(9600);
digitalWrite(greenLed, HIGH);
servo9.write(0);
Serial.println(“The box is unlocked!”);
}
void loop() {
if(locked == false) {
switchVal = digitalRead(switchPin);
if(switchVal == HIGH) {
locked = true;
digitalWrite(greenLed, LOW);
digitalWrite(redLed, HIGH);
servo9.write(90);
Serial.println(“The box is locked!”);
delay(1000);
}
}
if(locked == true) {
knockVal = analogRead(piezo);
if(numberOfKnocks 0) {
if(checkForKnock(knockVal) == true) {
numberOfKnocks++;
}
Serial.print(3 – numberOfKnocks);
Serial.println(” more knocks to go”);
}
if(numberOfKnocks >= 3) {
locked = false;
servo9.write(0);
delay(20);
digitalWrite(greenLed, HIGH);
digitalWrite(redLed, LOW);
Serial.println(“The box is unlocked!”);
}
}
}
boolean checkForKnock(int value) {
if(value > quietKnock && value < loudKnock) {
digitalWrite(yellowLed, HIGH);
delay(50);
digitalWrite(yellowLed, LOW);
Serial.print(“Valid knock of value “);
Serial.println(value);
return true;
}
else {
Serial.print(“Bad knock value “);
Serial.println(value);
return false;
}
}
ARDUINO11-Crystal Ball
THE CODE FOR 11
#include
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const int switchPin = 6;
int switchState = 0;
int prevSwitchState = 0;
int reply;
void setup() {
lcd.begin(16, 2);
pinMode(switchPin, INPUT);
lcd.print(“Ask the”);
lcd.setCursor(0, 1);
lcd.print(“Crystal Ball!”);
}
void loop() {
switchState = digitalRead(switchPin);
if(switchState != prevSwitchState) {
if(switchState == LOW) {
reply = random(8);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(“The Ball says: “);
lcd.setCursor(0, 1);
switch(reply) {
case 0:
lcd.print(“Yes”);
break;
case 1:
lcd.print(“Most likely”);
break;
case 2:
lcd.print(“Certainly”);
break;
case 3:
lcd.print(“Outlook good”);
break;
case 4:
lcd.print(“Unsure”);
break;
case 5:
lcd.print(“Ask again”);
break;
case 6:
lcd.print(“Doubtful”);
break;
case 7:
lcd.print(“No”);
break;
}
}
}
prevSwitchState = switchState;
}
16 Νοεμβρίου 2014
Music Controller with Kinect + openFrameworks + Mac
[youtube https://www.youtube.com/watch?v=IRpm9Qcnp-k]
Tutorial for Arduino:
[youtube https://www.youtube.com/watch?v=abWCy_aOSwY]
[youtube https://www.youtube.com/watch?v=PeScmRwzQho?list=PL5D114A4EF03B87E0]
ARDUINO10 -Zoetrope
const int controlPin1 = 2;
const int controlPin2 = 3;
const int enablePin = 9;
const int directionSwitchPin = 4;
const int onOffSwitchStateSwitchPin = 5;
const int potPin = A0;
int onOffSwitchState = 0;
int previousOnOffSwitchState = 0;
int directionSwitchState = 0;
int previousDirectionSwitchState = 0;
int motorEnabled = 0;
int motorSpeed = 0;
int motorDirection = 1;
void setup() {
pinMode(directionSwitchPin, INPUT);
pinMode(onOffSwitchStateSwitchPin, INPUT);
pinMode(controlPin1, OUTPUT);
pinMode(controlPin2, OUTPUT);
pinMode(enablePin, OUTPUT);
digitalWrite(enablePin, LOW);
}
void loop() {
onOffSwitchState = digitalRead(onOffSwitchStateSwitchPin);
delay(1);
directionSwitchState = digitalRead(directionSwitchPin);
motorSpeed = analogRead(potPin)/4;
if(onOffSwitchState != previousOnOffSwitchState) {
if(onOffSwitchState == HIGH) {
motorEnabled = !motorEnabled;
}
}
if (directionSwitchState != previousDirectionSwitchState) {
if (directionSwitchState == HIGH) {
motorDirection = !motorDirection;
}
}
if (motorDirection = 1) {
digitalWrite(controlPin1, HIGH);
digitalWrite(controlPin2, LOW);
}
else {
digitalWrite(controlPin1, LOW);
digitalWrite(controlPin2, HIGH);
}
if (motorEnabled == 1) {
analogWrite(enablePin, motorSpeed);
}
else {
analogWrite(enablePin, 0);
}
previousDirectionSwitchState = directionSwitchState;
previousOnOffSwitchState = onOffSwitchState;
}
[youtube https://www.youtube.com/watch?v=zaODBPJ8bBk&w=420&h=315]