Interactive window: Difference between revisions

From base48
imported>Hyna
(link)
imported>Cubz
No edit summary
Line 3: Line 3:


[http://vimeo.com/8196236 http://vimeo.com/8196236]
[http://vimeo.com/8196236 http://vimeo.com/8196236]
 
[http://sosolimited.com/hbo-snow-globe/] - a few more words about technologies used in the HBO window





Revision as of 10:55, 13 October 2012

Banik pičo

http://vimeo.com/8196236 [1] - a few more words about technologies used in the HBO window


Text


<syntaxhighlight lang="c"> int vetrak = 9; int adc_senzor = 0; float senzor = 0.0; int pwm = 0;


int eliminace_okoli = 30; // random sracky se senzoru

float minimal_pwm = 160; // pro kazdy vetrak jiny!

void setup() {

 // put your setup code here, to run once:
 Serial.begin(9600);

}

void loop() {

 // put your main code here, to run repeatedly: 
 adc_senzor = analogRead(A0);
 //senzor da max 3.2V, tzn prepocitat na plnej rozsah.
 // 5/3.2 = 1.5635

// 3.2V pode datasheetu, coz neni zas tak uplne pravdal. Proto to je jen 1.30

 if (adc_senzor*1.30 > 1023) {
     senzor = 1023;
     Serial.println("preteceni u senzor");
 } else {
   senzor = adc_senzor*1.30;
   
 }
   pwm = senzor/4; // ADC je do 1024, ale PWM jen do 256
   
   if (pwm < eliminace_okoli) {
     pwm = 0; // pri takto nizkych hodnotach povazujeme ze pred vylohou nikdo nestoji
   }
   
   if (pwm > 254) {
     Serial.println("preteceni u pwm"); // kdyby neco, tak nic
   } 
   
   //analogWrite(9, pwm);
 
 /* 
 zjsiteni kolik potrebuje vetrak na roztoceni
 for (int i=0; i <= 250; i=i+10){
     Serial.println(i); 
     analogWrite(9, i);
     delay(1000);
  } 
*/  
 
//  Serial.println(pwm);
 //delay(1000);
  analogWrite(9, pwm);
 

} </syntaxhighlight>