This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
notes:c4eng:fall2022:projects:fso1 [2022/11/16 22:12] – [DEMONSTRATION] mward14 | notes:c4eng:fall2022:projects:fso1 [2022/11/17 14:07] (current) – [DEMONSTRATION] cmille71 | ||
---|---|---|---|
Line 13: | Line 13: | ||
====OVERVIEW==== | ====OVERVIEW==== | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | |||
+ | #define rled 28 | ||
+ | #define yled 27 | ||
+ | #define buzzer | ||
+ | #define trigPin 4 | ||
+ | #define echoPin 5 | ||
+ | #define MAX_DISTANCE 220 // define the maximum measured distance | ||
+ | #define timeOut MAX_DISTANCE*60 // calculate timeout according to the maximum m$ | ||
+ | #define gled 1 | ||
+ | //function pulseIn: obtain pulse time of a pin | ||
+ | int pulseIn(int pin, int level, int timeout); | ||
+ | float getSonar(){ | ||
+ | long pingTime; | ||
+ | float distance; | ||
+ | digitalWrite(trigPin, | ||
+ | delayMicroseconds(10); | ||
+ | digitalWrite(trigPin, | ||
+ | pingTime = pulseIn(echoPin, | ||
+ | distance = (float)pingTime * 340.0 / 2.0 / 10000.0; //calculate distance wi$ | ||
+ | return distance; | ||
+ | } | ||
+ | |||
+ | int main(){ | ||
+ | printf(" | ||
+ | |||
+ | wiringPiSetup(); | ||
+ | softToneCreate (buzzer); | ||
+ | float distance = 0; | ||
+ | pinMode(trigPin, | ||
+ | pinMode(echoPin, | ||
+ | pinMode(gled, | ||
+ | // pinMode(buzzer, | ||
+ | while(1){ | ||
+ | distance = getSonar(); | ||
+ | printf(" | ||
+ | softToneWrite(buzzer, | ||
+ | if (distance> | ||
+ | { | ||
+ | digitalWrite(gled, | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | digitalWrite(gled, | ||
+ | } | ||
+ | if (distance< | ||
+ | { | ||
+ | digitalWrite(yled, | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | digitalWrite(yled, | ||
+ | } | ||
+ | if (distance< | ||
+ | { | ||
+ | digitalWrite(rled, | ||
+ | digitalWrite(yled, | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | digitalWrite(rled, | ||
+ | } | ||
+ | |||
+ | delay(10); | ||
+ | } | ||
+ | return 1; | ||
+ | } | ||
+ | |||
+ | int pulseIn(int pin, int level, int timeout) | ||
+ | { | ||
+ | | ||
+ | long micros; | ||
+ | | ||
+ | | ||
+ | while (digitalRead(pin) != level) | ||
+ | { | ||
+ | gettimeofday(& | ||
+ | if (tn.tv_sec > t0.tv_sec) micros = 1000000L; else micros = 0; | ||
+ | micros += (tn.tv_usec - t0.tv_usec); | ||
+ | if (micros > timeout) return 0; | ||
+ | } | ||
+ | | ||
+ | while (digitalRead(pin) == level) | ||
+ | { | ||
+ | gettimeofday(& | ||
+ | if (tn.tv_sec > t0.tv_sec) micros = 1000000L; else micros = 0; | ||
+ | micros = micros + (tn.tv_usec - t0.tv_usec); | ||
+ | if (micros > timeout) return 0; | ||
+ | } | ||
+ | if (tn.tv_sec > t1.tv_sec) micros = 1000000L; else micros = 0; | ||
+ | | ||
+ | | ||
+ | } | ||
====CIRCUIT==== | ====CIRCUIT==== | ||
Line 202: | Line 300: | ||
Seconds can be isolated by simply putting '' | Seconds can be isolated by simply putting '' | ||
- | =====PROJECT 7===== | + | =====Proximity Sensor===== |
====OVERVIEW==== | ====OVERVIEW==== | ||
+ | Basically my fso1 was a distance sensor with a buzzer and light system. As you get closer the buzzer gets higher pitched If distance> | ||
====CIRCUIT==== | ====CIRCUIT==== | ||
+ | {{: | ||
====DEMONSTRATION==== | ====DEMONSTRATION==== | ||
+ | {{ : | ||
=====PROJECT 8===== | =====PROJECT 8===== | ||
Line 244: | Line 342: | ||
- | =====PROJECT 11===== | + | ==========Model Rocket Thrust Vector Control (TVC)============ |
====OVERVIEW==== | ====OVERVIEW==== | ||
+ | In this project, I used the Adafruit Gy-521 and two Servos. These electronics were used for the goal of making sure that a model rocket is properly orientated during its flight and guaranteeing a nominal trajectory for it. | ||
- | ====CIRCUIT==== | + | The GY-521 is an accelerometer/ |
- | ====DEMONSTRATION==== | ||
=====PROJECT 12===== | =====PROJECT 12===== |