WEEK 1 – Component Research from Team members (group 8):

From these component researches we where able too take it through to next step of figuring out a way that we could create a program.

( Seven Segment Display Research )

Tharuka Selliah

A 7-segment display is commonly used in electronic display devices for decimal numbers from 0 to 9 and in some cases, basic characters. The use of light-emitting diodes (LEDs) in seven-segment displays made it more popular, whereas of late liquid crystal displays (LCD) have also come into use.

There are 2 types of Seven – segment Display:

Common Cathode Display:

In a common cathode seven-segment display, all seven LEDs plus a dot LED have the cathodes connected to pins 3 and pin 8. To use this display, we need to connect GROUND to pin 3 and pin 8 and,  and connect +5V to the other pins to make the individual segments light up.

Common Anode Display:

The common anode display is the exact opposite. In a common-anode display, the positive terminal of all the eight LEDs  are connected together and then connected to pin 3 and pin 8. To turn on an individual segment, you ground one of the pins. 

How does A seven segment Display Work:

A seven-segment display uses Light Emitting Diodes to release light energy in photons. The production emits light to show digits in all seven segments, with the eighth segment being a decimal point.

Where is Seven segment used:

  • Digital clocks
  • Electronic meters
  • Basic calculators
  • Displays in home appliances
  • Cars
  • Various other electronic devices that display numerical information

TinkerCad circuit layout:

TinkerCad Code:

unsigned const int A = 13;
unsigned const int B = 12;
unsigned const int C = 11;
unsigned const int D = 10;
unsigned const int E = 9;
unsigned const int F = 8;
unsigned const int G = 7;
unsigned const int H = 6;

void setup(void)
{
pinMode(A, OUTPUT);
pinMode(B, OUTPUT);
pinMode(C, OUTPUT);
pinMode(D, OUTPUT);
pinMode(E, OUTPUT);
pinMode(F, OUTPUT);
pinMode(G, OUTPUT);
pinMode(H, OUTPUT);
}

//My Functions

void zero(void) {
digitalWrite(A, LOW);
digitalWrite(B, HIGH);
digitalWrite(C, HIGH);
digitalWrite(D, HIGH);
digitalWrite(E, HIGH);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
digitalWrite(H, LOW);
}

void one(void) {
digitalWrite(A, LOW);
digitalWrite(B, LOW);
digitalWrite(C, LOW);
digitalWrite(D, HIGH);
digitalWrite(E, LOW);
digitalWrite(F, LOW);
digitalWrite(G, HIGH);
digitalWrite(H, LOW);
}

void two(void) {
digitalWrite(A, HIGH);
digitalWrite(B, LOW);
digitalWrite(C, HIGH);
digitalWrite(D, HIGH);
digitalWrite(E, HIGH);
digitalWrite(F, HIGH);
digitalWrite(G, LOW);
digitalWrite(H, LOW);
}

void three(void) {
digitalWrite(A, HIGH);
digitalWrite(B, LOW);
digitalWrite(C, HIGH);
digitalWrite(D, HIGH);
digitalWrite(E, LOW);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
digitalWrite(H, LOW);
}

void four(void) {
digitalWrite(A, HIGH);
digitalWrite(B, HIGH);
digitalWrite(C, LOW);
digitalWrite(D, HIGH);
digitalWrite(E, LOW);
digitalWrite(F, LOW);
digitalWrite(G, HIGH);
digitalWrite(H, LOW);
}

void five(void) {
digitalWrite(A, HIGH);
digitalWrite(B, HIGH);
digitalWrite(C, HIGH);
digitalWrite(D, LOW);
digitalWrite(E, LOW);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
digitalWrite(H, LOW);
}

void six(void) {
digitalWrite(A, HIGH);
digitalWrite(B, HIGH);
digitalWrite(C, HIGH);
digitalWrite(D, LOW);
digitalWrite(E, HIGH);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
digitalWrite(H, LOW);
}

void seven(void) {
digitalWrite(A, LOW);
digitalWrite(B, LOW);
digitalWrite(C, HIGH);
digitalWrite(D, HIGH);
digitalWrite(E, LOW);
digitalWrite(F, LOW);
digitalWrite(G, HIGH);
digitalWrite(H, LOW);
}

void eight(void) {
digitalWrite(A, HIGH);
digitalWrite(B, HIGH);
digitalWrite(C, HIGH);
digitalWrite(D, HIGH);
digitalWrite(E, HIGH);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
digitalWrite(H, LOW);
}

void nine(void) {
digitalWrite(A, HIGH);
digitalWrite(B, HIGH);
digitalWrite(C, HIGH);
digitalWrite(D, HIGH);
digitalWrite(E, LOW);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
digitalWrite(H, LOW);
}

// Start
void loop(void)
{
zero();
delay(1000);

one();
delay(1000);

two();
delay(1000);

three();
delay(1000);

four();
delay(1000);

five();
delay(1000);

six();
delay(1000);

seven();
delay(1000);

eight();
delay(1000);

nine();
delay(1000);
}

Pseudo Code Flowchart:

Video Explanation:

Code Explanation:

This code is written for an Arduino board, and it displays the numbers 0 to 9 on a seven-segment display using the GPIO pins. The GPIO pins A to G are used to control the segments of the display, while pin H is used to control a decimal point if present. The code defines functions for each number, and each function sets the appropriate pins to turn on the corresponding segments. The setup function is used to set the pinMode for each pin as an OUTPUT. The loop function calls each number function in turn with a delay of 1 second between each number, resulting in a sequence of digits being displayed on the seven-segment display.

Note that this code assumes that the seven-segment display is connected to the Arduino board in a specific way, with each segment connected to a specific GPIO pin. If the display is connected differently, the functions will need to be modified accordingly.

This code is an example of using a microcontroller to control a seven-segment display to display the numbers 0-9 sequentially with a delay of one second between each number.

The code defines constants A-H to represent the pins of the microcontroller that are connected to the seven-segment display. It then defines functions for each number from 0-9 that turn on the appropriate segments of the display to form the desired number.

In the loop function, each number is displayed in sequence by calling its corresponding function and then delaying for one second using the delay function. This process repeats indefinitely until the microcontroller is reset or powered off.

Refrences:

LIGHT EMITTING DIODE – WESLEY MOORE

REFERENCES

Blink. (n.d.). Arduino Documentation. https://docs.arduino.cc/built-in-examples/basics/Blink

D. (2022, February 18). How to use a RGB LED with Arduino | Tutorial. How to Mechatronics. https://howtomechatronics.com/tutorials/arduino/how-to-use-a-rgb-led-with-arduino/?utm_content=cmp-true

E. (2021, October 5). Arduino – Handle Multiple LEDs Using Arrays and Functions. The Robotics Back-End. https://roboticsbackend.com/arduino-handle-multiple-leds-using-arrays-and-functions/

Badru, H. A. (n.d.). Blinking LEDs Using Arduino Microcontrollerhttp://hassanmicroprocessors.blogspot.com/2011/09/blinking-leds-using-arduino.htmlc

Toggle Sidebar

24/02/2023

SWITCHES AND BUTTONS INDIVIDUAL RESEARCH – JOSE D.

SWITCHES IN A CIRCUIT:

It is a component which controls the opening and closing of an electric circuit allowing the control of the current through it.

The TinkerCAD model above shows a simple circuit consisting of an LED, a resistor and a slide switch powered by a 3V battery.

  • Switches are critical components which require user interaction or control.
  • A switch can be placed anywhere in a circuit.

PUSH BUTTON SWITCH:

It enables the electricity to flow through the circuit when it is held in, our circuit will be powered by an Arduino circuit board which will allow the control of the function.

As shown below:

The TinkerCAD circuit displays an Arduino circuit board coded for the opening of the current to the LED whenever the push button switch is held.

CODE:

The code used for the model above:

int ledPin = 7;
int buttonPin = 2;
int buttonState = 0;
void setup()
  
{
  pinMode(ledPin, OUTPUT);
  pinMode(buttonPin, INPUT);
  
  Serial.begin(9600);
}
void loop()
{

  buttonState = digitalRead(buttonPin);
  
  if (buttonState == HIGH){
    
    Serial.println("ON");
    digitalWrite(ledPin, HIGH);
    
  } else {
    
    Serial.println("OFF");
    digitalWrite(ledPin, LOW);
    
  }}

SWITCHES IN CODING:

A switch statement is a type of selection control mechanism used to allow the value of a variable or expression to change the control flow of program execution:

  • As shown above in the flowchart, it allows a variable to be tested for equality against a list of values.

References:Types of switches; https://byjus.com/physics/types-of-switches/ ,

A Complete Guide to Button switches; https://uk.rs-online.com/web/content/discovery/ideas-and-advice/push-button-switches-guide

C – switch statement; https://www.tutorialspoint.com/cprogramming/switch_statement_in_c.htm

KAT N INDIVIDUAL RESEARCH BUZZER

LINK FOR THE VIDEO

https://uwe.cloud.panopto.eu/Panopto/Pages/Viewer.aspx?id=c4b706b2-4533-40df-98f9-afb30050b229