User Tools

Site Tools


Sidebar

projects

wcp1 (due 20240828)
wcp2 (due 20240904)
pct0 (bonus; due 20240905)
pct1 (bonus; due 20240905)
pct2 (due 20240905)
abc0 (due 20240906)
gtf0 (due 20240911)
pct3 (bonus; due 20240911)
wcp3 (due 20240911)
dtr0 (due 20240918)
pct4 (due 20240918)
wcp4 (due 20240918)
pct5 (bonus; due 20240926)
stl0 (due 20240926)
wcp5 (due 20240926)
gfo0 (due 20241002)
pct6 (due 20241002)
stl1 (due 20241002)
wcp6 (due 20241002)
pct7 (bonus; due 20241009)
stl2 (due 20241009)
wcp7 (due 20241009)
bwp1 (bonus; due 20241016)
pct8 (due 20241016)
ptb0 (due 20241016)
wcp8 (due 20241016)
pct9 (bonus; due 20241023)
ptb1 (due 20241023)
wcp9 (due 20241023)
gfo1 (due 20241030)
pctA (due 20241030)
ptb2 (due 20241030)
wcpA (due 20241030)
pctB (bonus; due 20241106)
wcpB (due 20241106)
wus0 (due 20241106)
pctC (due 20241113)
wcpC (due 20241113)
wus1 (due 20241113)
pctD (bonus; due 20241120)
wcpD (bonus; due 20241120)
wus2 (due 20241120)
bwp2 (bonus; due 20241204)
gfo2 (due 20241204)
pctE (bonus; due 20241204)
wcpE (bonus; due 20241204)
EoCE (due 20241216)
haas:fall2024:c4eng:projects:fso1

Corning Community College

ENGR1050 C for Engineers

PROJECT: Figure Something Out (FSO1)

OBJECTIVE

Take your explored component and prototype something you'd like to create with it. Start writing software to test various aspects of the desired end product.

Be sure to contribute useful background and operational information to this project documentation, to serve as a reference for others.

OVERVIEW

Your task is to:

  • apply your knowledge of the component to build something that uses it
  • write a program that demonstrates aspects of the desired functionality
  • there will be one more part to this project, so if you want to take a broader-term view:
    • fso0: figure out how to use some component
    • fso1: prototype some circuit putting it to greater use
    • fso2: finished product

Example:

  • fso0: figure out how to use an ultrasonic sensor
  • fso1: prototype a “useless” machine, using the ultrasonic sensor as a proximity sensor to determine if the user's hand is still near the switch (to avoid injury)
  • fso2: finished product of a “useless” machine

GRABIT

To assist with consistency across all implementations, data files for use with this project are available on lab46 via the grabit tool. Be sure to obtain it and ensure your implementation properly works with the provided data.

lab46:~/src/SEMESTER/DESIG$ grabit DESIG PROJECT

EDIT

You will want to go here to edit and fill in the various sections of the document:

ultrasonic sensor & lcd 1605 desplay screen

OVERVIEW

LCD1602, or 1605 character-type liquid crystal display, is a kind of dot matrix module to show letters, numbers, and characters and so on. It's composed of 5×7 or 5×11 dot matrix positions; each position can display one character. There's a dot pitch between two characters and a space between lines, thus separating characters and lines. The model 1605 means it displays 2 lines of 16 characters. Generally, LCD1605 has parallel ports, that is, it would control several pins at the same time. LCD1605 can be categorized into eight-port and four-port connections. If the eight-port connection is used, then all the digital ports of the SunFounder Uno board are almost completely occupied. If you want to connect more sensors, there will be no ports available. Therefore, the four-port connection is used here for better application.

use

i was able to use this display screen to show the measurement of the prox senser

DEMONSTRATION

Proximity Alarm

OVERVIEW

#include <wiringPi.h> #include <stdio.h> #include <sys/time.h> #include <softTone.h> #include <stdlib.h> #include <math.h>

#define rled 28 #define yled 27 #define buzzer 8 #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(){ get the measurement result of ultrasonic module with unit$

  long pingTime;
  float distance;
  digitalWrite(trigPin,HIGH); //send 10us high level to trigPin
  delayMicroseconds(10);
  digitalWrite(trigPin,LOW);
  pingTime = pulseIn(echoPin,HIGH,timeOut);   //read plus time of echoPin
  distance = (float)pingTime * 340.0 / 2.0 / 10000.0; //calculate distance wi$
  return distance;

}

int main(){

  printf("Program is starting ... \n");
  wiringPiSetup();
  softToneCreate (buzzer);
  float distance = 0;
  pinMode(trigPin,OUTPUT);
  pinMode(echoPin,INPUT);
  pinMode(gled, OUTPUT);

pinMode(buzzer, OUTPUT); while(1){ distance = getSonar(); printf(“The distance is : %.2f cm\n”,distance); softToneWrite(buzzer, 1000-distance*15); if (distance>=20) { digitalWrite(gled, HIGH); } else { digitalWrite(gled, LOW); } if (distance<20) { digitalWrite(yled, HIGH); } else { digitalWrite(yled, LOW); } if (distance<10) { digitalWrite(rled, HIGH); digitalWrite(yled, LOW); } else { digitalWrite(rled, LOW); } delay(10); } return 1; } int pulseIn(int pin, int level, int timeout) { struct timeval tn, t0, t1; long micros; gettimeofday(&t0, NULL); micros = 0; while (digitalRead(pin) != level) { gettimeofday(&tn, NULL); if (tn.tv_sec > t0.tv_sec) micros = 1000000L; else micros = 0; micros += (tn.tv_usec - t0.tv_usec); if (micros > timeout) return 0; } gettimeofday(&t1, NULL); while (digitalRead(pin) == level) { gettimeofday(&tn, NULL); 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; micros = micros + (tn.tv_usec - t1.tv_usec); return micros; } ====CIRCUIT==== ====DEMONSTRATION==== =====Ultrasonic sensor with LED bar graph feedback===== ====OVERVIEW==== This project incorporates the LED bar graph to display distance feedback from the ultrasonic sensor. The closer that the object is to the sensor, the less LED lights will be on, the further it is the more LED lights will be on. The Ultrasonic sensor emits ultrasonic pulses that bounces off an object and receives the reverberation to sense how far and object is from the sensor. The LED bar graph is comprised of 10 individual LED lights Components Needed; - Breadboard
- 14 jumper wires
- 10 220ohm resistors
- 3 1kohm resistors
- Ultrasonic Sensor
- LED Bar Graph
====CIRCUIT==== LED Bar Graph Ultrasonic Sensor ====DEMONSTRATION==== Using the code provided by freenove contained in chapter 24 (Ultrasonic Ranging) of the tutorial file, add the wiringPi pins for the LEDs. <code> #define LED1 0
Defining wPi pins for LEDs in bar graph #define LED2 1 #define LED3 2 #define LED4 3 #define LED5 4 #define LED6 5 #define LED7 6 #define LED8 28 #define LED9 29 #define LEDA 10 </code>

I chose to use the define command as I want to have the ability to command each LED independently rather than use an array. In order to use these LED's we have to set those pins to outputs.

pinMode(LED1, OUTPUT); 

Make sure you repeat this for all 10 LED wPi pins

Since we are using the declared variable of distance for the numerical distance and the max distance is 220, I will set up a for loop

for(distance = 0; distance < 220;)

This will ensure the code will continue to loop as long as we are within those parameters

Next, we have to use if/else statements using the variable distance and setting each additional LED to come on when we increase the distance in increments of 22cm.

if (distance > 0)                       // 1 led will come on if distance is greater than 0cm
            {
                digitalWrite(LED1, LOW);
            }
            else
            {
                digitalWrite(LED1, HIGH);
            }
            
            if (distance > 22)                      // 2 LEDs will come on if distance exceeds 22cm
            {
                digitalWrite(LED2, LOW);
            }
            else
            {
                digitalWrite(LED2, HIGH);
            }

Note, I am using the GPIO on the anode side of the LED, so commanding the LED low means that it is being commanded on. This must be repeated for all 10 LEDs. Notice that we are are using open ended greater than statements so that way the LEDs will increment up the bar graph and give us a nice visual indicator of the distance from the ultrasonic sensor.

At the end of the for statement, we include a printf function to display the input of the ultrasonic sensor and also a delay to update the input every 500ms.

LED Lights, Proximity Sensor and LCD

OVERVIEW

In this project, I used three LEDs (red, yellow and green), a proximity sensor, and a lcd. Using the proximity sensor changes the color of the LEDs and changes the distance of the lcd.

An LED light is an electronic device that emits light when an electric current flows through it. So, an LED converts electrical energy into a light source. LED lights can also be used as an ON/OFF switch for a specific duration of code.

A proximity sensor is a device that can detect or sense the approach or presence of nearby objects without touching it. These sensors also convert the information that is received from the approach or presence of the objects into an electrical signal.

Wiring the LEDs and the proximity sensor.

Parts Needed: Arduino Uno, LED x3, Breadboard, Ultrasonic Distance Sensor - HC-SR04, Wires.

A Liquid Crystal Display (LCD) is an electronic device, which is frequently used in many applications for displaying information in a text or image format. An LCD is used for displaying the alphanumeric character on its screen. Alphanumeric characters are the numbers 0-9 and letters A-Z (both uppercase and lowercase). The LCD display is consists of 8-data lines and 3-control lines which are used for interfacing the LCD display with 8051 microcontroller.

Wiring the LCD

Parts Needed: Arduino Uno, Breadboard, 4 wires, the LCD.

As an object moves in front of the proximity sensor the LEDs light up and the LCD changes. If an object is very close to the proximity sensor then the red LED lights up and the LCD calculates the distance. If the object is halfway to the proximity sensor then the yellow LED lights up and the LCD calculates the distance. If an object is very faraway from the proximity sensor then the green LED lights up and the LCD calculates the distance.

The LCD recorded the distance as the object became closer or moved away.

Joystick Controlling LED Matrix 8 by 8

Within this project I used a Joystick and 8 by 8 LED board. Using the Joystick it lights up a singular LED on the board and can be controlled by moving the joystick around.

A Joystick is a kind of input sensor used with your fingers. You should be familiar with this concept already as they are widely used in gamepads and remote controls. It can receive input on two axes (Y and or X) at the same time (usually used to control direction on a two dimensional plane). And it also has a third direction capability by pressing down (Z axis/direction). Wiring the joystick

Parts Needed: Raspberry Pi, Ribbon cable, Breadboard, Joysick, 10k Resistor, ADC module, Wires

An LED Matrix is a rectangular display module that consists of a uniform grid of LEDs. The following is an 8×8 monochrome (one color) LED Matrix containing 64 LEDs (8 rows by 8 columns). Wiring the 8 by 8 matrix

Parts Needed: Raspberry Pi, Ribbon cable, Breadboard, 8 220 Resistors, 8by8 LED Matrix, Wires, 2 74HC595

The Joystick prints out x and y values (as of right now z axis does not do anything I will improve upon it in fso2). The code records the values then, the code determines whether the values are high or low enough to move the LED on the Matrix (the coordinates show which LED is lit up).

val_X: 128 , val_Y: 127 , val_Z: 1 [0, 0] val_X: 128 , val_Y: 127 , val_Z: 1 [0, 0] val_X: 128 , val_Y: 127 , val_Z: 1 [0, 0] val_X: 0 , val_Y: 254 , val_Z: 1 [1, 1] val_X: 0 , val_Y: 254 , val_Z: 1 [1, 2] val_X: 0 , val_Y: 254 , val_Z: 1 [1, 3] val_X: 0 , val_Y: 254 , val_Z: 1 [1, 4] val_X: 253 , val_Y: 0 , val_Z: 1 [2, 3] val_X: 253 , val_Y: 0 , val_Z: 1 [4, 2] val_X: 128 , val_Y: 127 , val_Z: 1 [4, 2] val_X: 254 , val_Y: 254 , val_Z: 1 [8, 3] val_X: 254 , val_Y: 254 , val_Z: 1 [16, 4] val_X: 0 , val_Y: 127 , val_Z: 1 [8, 4] val_X: 0 , val_Y: 127 , val_Z: 1

16x2 LCD with LEDs

OVERVIEW

I used LEDs to replace the seconds component of the LCD screen and removed the seconds and milliseconds from the display so it only displays hours and minutes. This is made to separate the seconds component from the system time and mathematically derive what LEDs should be lit and which ones should not.

CIRCUIT

The LCD screen is wired like before: VCC pin being connected to 5v, GND connected to ground, SDA connected to an SDA Pi pin, and SCL connected to an SCL pin on the Pi.

The LEDs are also wired how we have wired them in the past. Each LED is wired to a common ground with the other lead of the LED connected to a different GPIO pin, all with 220Ω resistors.

Code

This LCD screen utilizes a library written in python so the code for the LEDs are as well. Python is very similar to C with only minor syntax differences for what is used for this project.

the datetime.now() function will take the current time to the millisecond and apply it to a choses variable.

time = datetime.now() will set the variable “time” to the current system time from hours through milliseconds.

Seconds can be isolated by simply putting .second at the end of the variable name. so time.second will be the isolated second value.

Proximity Sensor

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>30cm the green light was on and the buzzer was off. If distance<30cm the yellow light turned on and the green light turned off. If distance<10cm the red light turned on and the yellow light turned off.

CIRCUIT

DEMONSTRATION

PROJECT 8

OVERVIEW
CIRCUIT
DEMONSTRATION

SMART DOOR

OVERVIEW

You might have seen Automatic Door Opener Systems at shopping malls, cinemas, hospitals etc. where, as soon as a person approaches the door (at about 2 or 3 feet), the door automatically slides open. And after some time (about 5 to 10 seconds), the door closes by sliding in the reverse direction This will be a smaller scale, homemade version using just a simple cardboard box.

CIRCUIT

Sensor: The PIR motion sensor has 3 pins. One for ground, one for 5v, and one output. LED: Plug the shorter leg of the LED to a hole on the breadboard. Connect that leg to a GND pin of the Arduino, Plug the longer leg of the LED to a different hole, on a different and independent line of the breadboard. Add a 220 Ohm resistor between this longer leg and a digital pin of the Arduino Servo motor: Like the PIR sensor, the servo has 3 pins. One for 5V, one for ground, and one signal wire.

DEMONSTRATION

When an object or person gets close to the door, it will automatically open.

4 Digit 7 Segment LED Display with Button

OVERVIEW

The 4 digit display when wired to the pi acts as a counter that begins at 0 and counts up to 9999. It increases by 1 second at a time so it acts as a timer of sorts. With the button wired to it in the form of a lamp switch button, it makes the counter able to be stopped. The timer begins counting when started and when the button is press once, the timer will stop. When the button is pressed again, the timer will continue counting up.

CIRCUIT

Model Rocket Thrust Vector Control (TVC)

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.

The GY-521 is an accelerometer/gyroscope that will detect a change in the orientation of the craft as it is flying and will send a signal to the Arduino that the orientation of the craft is off. This will then send a signal to the servos that the orientation is off and needs to be fixed. Determining how much of a correction needs to be made is determined by a Proportional Integral Derivative (PID). A device that will automatically apply an accurate and responsive correction to a control function. This basically determines how fast/ intensely the servo responds to an error in the orientation of the device.

PROJECT 12

OVERVIEW
CIRCUIT
DEMONSTRATION

PROJECT 13

OVERVIEW
CIRCUIT
DEMONSTRATION

PROJECT 14

OVERVIEW
CIRCUIT
DEMONSTRATION

PROJECT 15

OVERVIEW
CIRCUIT
DEMONSTRATION

PROJECT 16

OVERVIEW
CIRCUIT
DEMONSTRATION

PROJECT 17

OVERVIEW
CIRCUIT
DEMONSTRATION
 

SUBMISSION

To be successful in this project, the following criteria (or their equivalent) must be met:

  • Project must be submit on time, by the deadline.
    • Late submissions will lose 33% credit per day, with the submission window closing on the 3rd day following the deadline.
  • All code must compile cleanly (no warnings or errors)
    • Compile with the -Wall and –std=gnu18 compiler flags
    • all requested functionality must conform to stated requirements (either on this document or in a comment banner in source code files themselves).
  • Executed programs must display in a manner similar to provided output
    • output formatted, where applicable, must match that of project requirements
  • Processing must be correct based on input given and output requested
  • Output, if applicable, must be correct based on values input
  • Code must be nicely and consistently indented
  • Code must be consistently written, to strive for readability from having a consistent style throughout
  • Code must be commented
    • Any “to be implemented” comments MUST be removed
      • these “to be implemented” comments, if still present at evaluation time, will result in points being deducted.
      • Sufficient comments explaining the point of provided logic MUST be present
  • No global variables (without instructor approval), no goto statements, no calling of main()!
  • Track/version the source code in your lab46 semester repository
  • Submit a copy of your source code to me using the submit tool (make submit on lab46 will do this) by the deadline.

Submit Tool Usage

Let's say you have completed work on the project, and are ready to submit, you would do the following:

lab46:~/src/SEMESTER/DESIG/PROJECT$ make submit

You should get some sort of confirmation indicating successful submission if all went according to plan. If not, check for typos and or locational mismatches.

RUBRIC

I'll be evaluating the project based on the following criteria:

78:fso1:final tally of results (78/78)
*:fso1:used grabit to obtain project by the Sunday prior to duedate [13/13]
*:fso1:overview of project pursued to project page with description [13/13]
*:fso1:picture of project circuit to project page with description [13/13]
*:fso1:clean compile, no compiler messages [13/13]
*:fso1:program conforms to project specifications [13/13]
*:fso1:code tracked in lab46 semester repo [13/13]

Pertaining to the collaborative authoring of project documentation

  • each class member is to participate in the contribution of relevant information and formatting of the documentation
    • minimal member contributions consist of:
      • near the class average edits (a value of at least four productive edits)
      • near the average class content change average (a value of at least 256 bytes (absolute value of data content change))
      • near the class content contribution average (a value of at least 1kiB)
      • no adding in one commit then later removing in its entirety for the sake of satisfying edit requirements
    • adding and formatting data in an organized fashion, aiming to create an informative and readable document that anyone in the class can reference
    • content contributions will be factored into a documentation coefficient, a value multiplied against your actual project submission to influence the end result:
      • no contributions, co-efficient is 0.50
      • less than minimum contributions is 0.75
      • met minimum contribution threshold is 1.00

Additionally

  • Solutions not abiding by spirit of project will be subject to a 50% overall deduction
  • Solutions not utilizing descriptive why and how comments will be subject to a 25% overall deduction
  • Solutions not utilizing indentation to promote scope and clarity or otherwise maintaining consistency in code style and presentation will be subject to a 25% overall deduction
  • Solutions not organized and easy to read (assume a terminal at least 90 characters wide, 40 characters tall) are subject to a 25% overall deduction
haas/fall2024/c4eng/projects/fso1.txt · Last modified: 2022/10/31 14:08 by 127.0.0.1