Posts

Showing posts from September, 2018

lab Day 7 sound, motor and rand# lab

Image
int speakerPin = 9; void setup()  { }//close setup void loop()  { tone(9,660,100); delay(150); tone(9,660,100); delay(300); tone(9,660,100); delay(300); tone(9,510,100); delay(100); tone(9,660,100); delay(300); tone(9,770,100); delay(550); tone(9,380,100); delay(575); tone(9,510,100); delay(450); tone(9,380,100); delay(400); tone(9,320,100); delay(500); tone(9,440,100); delay(300); tone(9,480,80); delay(330); tone(9,450,100); delay(150); tone(9,430,100); delay(300); tone(9,380,100); delay(200); tone(9,660,80); delay(200); tone(9,760,50); delay(150); tone(9,860,100); delay(300); tone(9,700,80); delay(150); tone(9,760,50); delay(350); tone(9,660,80); delay(300); tone(9,520,80); delay(150); tone(9,580,80); delay(150); tone(9,480,80); delay(500); } #include < stdio.h > int main( void ){ int num = 1 , dice1, dice2, i, sum[ 8 ]; while (num...

Day 5 rgb temp sensor and wave length

Image
const int hot = 25; //set hot const int cold = 23; //set cold const int BLED=9; const int GLED=10; const int RLED=11; int ledMode = 0; void setup() { pinMode(A0, INPUT); //sensor pinMode(BLED, OUTPUT); //blue pinMode(GLED, OUTPUT); //green pinMode(RLED, OUTPUT); //red Serial.begin(9600); } void loop() { int sensor = analogRead(A0); double voltage = (sensor / 1024.0) * 5.0; double tempC = (voltage - .5) * 100; if (tempC < cold) { //cold digitalWrite(BLED,HIGH); digitalWrite(GLED, LOW); digitalWrite(RLED, LOW); } if (tempC >= hot) { //hot   digitalWrite(RLED, HIGH); digitalWrite(BLED, LOW); digitalWrite(GLED, LOW); } else { //neutral   digitalWrite(GLED, HIGH); digitalWrite(BLED, LOW); digitalWrite(RLED, LOW); } delay(10); }

audino & weight calculator

Image
below is a picture with the four led bulbs // the setup function runs once when you press reset or power the board void setup() {   // initialize digital pin LED_BUILTIN as an output.   pinMode(10, OUTPUT); } // the loop function runs over and over again forever void loop() {    pinMode(12, OUTPUT);   digitalWrite(12, HIGH);   delay(100);   digitalWrite(12, LOW);   delay(100);   digitalWrite(10, HIGH);   delay(120);                    digitalWrite(10, LOW);   delay(120);                    pinMode(7, OUTPUT);   digitalWrite(7, HIGH);   delay(130);   digitalWrite(7, LOW);   delay(130);      pinMode(2, OUTPUT);   digitalWrite(2, HIGH);   delay(140);   digitalWrite(2, LOW);   delay(140);          pi...