First attemp coniglio with incomplete code

image

The initial plan

I started around 7pm. and decide to stop around 11.15. The circuit was completed. The code was simple and working well separately but when combined, the force sensor and buzzer combination failed.

image

What does the plan looks like in board and wires

image

Seems perfect and beautiful


Somewhere in these code I gave up.

//Project Coniglio
//Started 2012/11/06
//elvinado

const int photorPin = 0;
const int forcerPin = 2;
const int tiltPin = 7;

const int buzzPin = 9;
const int led1Pin = 3; //head lamp analogWrite PWM
const int led2Pin = 4; //eye digitalWrite
const int led3Pin = 2; //eye digitalWrite

void setup()
{
pinMode(photorPin,INPUT);
pinMode(forcerPin,INPUT);
pinMode(tiltPin,INPUT);

//pinMode(buzzPin,OUTPUT);
pinMode(led1Pin,OUTPUT);
pinMode(led2Pin,OUTPUT);
pinMode(led3Pin,OUTPUT);
}

void loop()
{

/*****Setup logic for photoresistor, analog input*****/
int light;
light = analogRead(photorPin); //read photoresistor value
//if the light less than certain value the all led off
//if the light more led 2 and 3 will lights up digitally
//led 1 will gradually become brighter the darker it gets
//dark threshold is 50
//dark is low number bright is high number
constrain(light,80,255);
if (light < 80)
{ digitalWrite(led2Pin,HIGH);
digitalWrite(led3Pin,HIGH);
analogWrite(led1Pin, 255 - light);
}
else
{
digitalWrite(led2Pin,LOW);
digitalWrite(led3Pin,LOW);
analogWrite(led1Pin, 0);
}

/*****setup logic for force resistor, analog input*****/
int force;
force = analogRead(forcerPin);
//read force resistor value
//use tone function
//the more force the higher the tone value
//force range 0-1000
int thisPitch = map (force, 0, 1000, 600,700);

if (force > 0)
{
analogWrite(buzzPin, thisPitch);
}
else
{
}

/*****setup logic for tilt sensor, digital input*****/
boolean tilt;
tilt = digitalRead(tiltPin); //read force resistor value
//when tilted wrongly the buzzer make specific tone
// wire downside = 1 ,wire upside = 0
delay(100);
}

image

Failed despite the elegance and simplicity of the idea (after 3 hours of tinkering)

Advertisements

One response to “First attemp coniglio with incomplete code

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: