08.11.2017 Views

arduino_básico_Michael_McRoberts

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Capítulo 14 ■ Telêmetros ultrassônicos<br />

337<br />

void displayDigit(float value) {<br />

int number = value*100;<br />

lc.setDigit(0,4,number/10000,false); // dígito das centenas<br />

lc.setDigit(0,3,(number%10000)/1000,false); // dígito das dezenas<br />

lc.setDigit(0,2,(number%1000)/100,true); // primeiro dígito<br />

lc.setDigit(0,1,(number%100)/10,false); // dígito dos décimos<br />

lc.setDigit(0,0,number%10,false);<br />

// dígito dos centésimos<br />

}<br />

// lê o potenciômetro<br />

float readPot() {<br />

float potValue = analogRead(potPin);<br />

alarmRange = 254 * (potValue/1024);<br />

return alarmRange;<br />

}<br />

// dispara o alarme, até que a reinicialização seja pressionada<br />

void startAlarm() {<br />

while(1) {<br />

for (int freq=800; freq

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!