1. Week 1 : Project Management
  2. Week 2 : Computer-aided
  3. Week 3 : Computer Controlled Cutting
  4. Week 4 : Embedded Programming
  5. Week 5 :3D Scanning and Printing
  6. Week 6 : Electronic Design
  7. Week 7 : Computer Controlled Machining
  8. Week 8 : Electronics Production
  9. Week 9 : Input Devices
  10. Week 10 : Output Devices
  11. Week 11 : Networking and Communication
  12. Week 12 : Mechanical Design and Machine Design
  13. Week 13 : Midterm Review
  14. Week 14 : Molding and Casting
  15. Week 15 : Interface and Application Programming
  16. Week 16 : System Integeration
  17. Week 17 : Wildcard Week
  18. Week 18 : Applications and Implications, Project Development
  19. Week 19 : Invention, Intellectual property and Income

Week 9:Input Devices

This week describes my understanding of how to use Input Devices. It also includes how to generate an analog output (PWM) using pin 9, how to use an oscilloscope and multimeter for analysis, and how to integrate different sesnor with the microcontroller.

Interpret a Signal

We generate an analog output (PWM) using pin 9. A LED is connected to see the signal effect, and the oscilloscope and multimeter are used for analysis.

Description of Image


1. Understanding DSO Components

  • Power Button: Turns the DSO ON/OFF.
  • Display Screen: Shows the waveform.
  • Probe Inputs (CH1, CH2): Connect the oscilloscope probes here.
  • Time/Div Knob: Adjusts the time scale (horizontal axis).
  • Volts/Div Knob: Adjusts the voltage scale (vertical axis).
  • Trigger Controls: Helps stabilize the waveform.

2. Connecting the Oscilloscope to Arduino

A. Connect the Probe Correctly

  • Turn OFF the oscilloscope before connecting anything.
  • Take one oscilloscope probe and connect:
    • Probe Tip: To Arduino PWM Pin 9 (or any analog pin you are testing).
    • Probe Ground (Clip): To Arduino GND (Ground).
  • Power up the Arduino and DSO.

3. Configuring the Oscilloscope for Basic Signal Viewing

A. Set the Channel

  • Press the CH1 button to activate Channel 1 (where we connected the probe).
  • If using two probes, press CH2 for the second channel.

B. Adjust the Voltage Scale (Vertical Setting)

  • Use the Volts/Div knob to set the voltage range.
  • Start with 1V/div and increase if needed.
  • For a 5V Arduino signal, set it around 2V/div for better viewing.

C. Adjust the Time Scale (Horizontal Setting)

  • Use the Time/Div knob to set the time range.
  • If measuring PWM signals (~500Hz), start with 1ms/div.
  • If measuring fast signals (above 1kHz), use 100µs/div.

D. Set the Trigger for a Stable Display

  • Press the Trigger Menu and set:
    • Mode: Edge
    • Source: CH1
    • Slope: Rising Edge
    • Level: Adjust until the waveform stabilizes

4. Running the Oscilloscope & Viewing the Waveform

  • Press AUTOSET (if available) to let the DSO automatically adjust settings.
  • If AUTOSET doesn’t work well, manually tweak Volts/Div and Time/Div.
  • Observe the waveform:
    • If using PWM output, you should see a square wave.
    • If using an analog sensor, the waveform may look more irregular.
  • Use Cursors or Measurements (if your DSO has them) to check signal values.

5. Capturing & Analyzing the Waveform

  • If your oscilloscope has a Save function, take a screenshot of the waveform.
  • Compare the output with the expected Arduino signal.
  • Adjust your Arduino code if needed to modify the signal.

                void setup() {
                pinMode(9, OUTPUT);
                }

                void loop() {
                for (int u = 0; u < 255; u++){
                    analogWrite(9, u);
                    delay(50);
                }
                }
            

Video Demonstration

For Group Assignment Refer here

Joystick Module

The Joystick Module consists of two potentiometers, each controlling an axis (X and Y).

Reading Joystick Module

Connect the joystick to Arduino: A0 and A1 for analog readings, pin 2 for the button.


                    int x_Pin = A0;
                    int y_Pin = A1;
                    int button_Pin = 2;

                    void setup(){
                        Serial.begin(9600);
                        pinMode(button_Pin, INPUT_PULLUP);
                   }

                    void loop(){
                        Serial.print("X: "); Serial.print(analogRead(x_Pin));
                        erial.print("\tY: "); Serial.print(analogRead(y_Pin));
                        Serial.print("\tButton: "); Serial.println(digitalRead(button_Pin));
                    delay(100);
                    }
                

Joystick Axis Values

Axis XAxis Y
Up1023527
Down0527
Right5121023
Left5120
Center512527

Video Demonstration




Temperature Sensor LM35


Description of Image

The LM35 is an analog temperature sensor with an output range of 0V to 1.5V.

Description of Image



                float temp = 0.0;
                int temp_Pin = 0;

                void setup(){
                    Serial.begin(9600);
                }
                void loop(){
                    temp = analogRead(temp_Pin);
                    Serial.print("temperature: ");
                    Serial.println(temp);
                    delay(100);
                }
            

Converting to Celsius

float temp_C = (5.0 * temp * 100.0) / 1024.0;


Ultrasonic Sensor HC-SR04

The HC-SR04 sensor calculates distance using ultrasonic waves.

Description of Image


            const int Trig = 2;
            const int Echo = 3;
            float tim = 0.0;
            float dist = 0.0;

            void setup(){
                Serial.begin(9600);
                pinMode(Trig, OUTPUT);
                pinMode(Echo, INPUT);
                digitalWrite(Trig, LOW);
            }

            void loop(){
                digitalWrite(Trig, HIGH);
                delayMicroseconds(10);
                digitalWrite(Trig, LOW);
                tim = pulseIn(Echo, HIGH);
                dist = tim / 59.0;
                Serial.print("Distance: ");
                Serial.print(dist);
                Serial.println(" cm");
                delay(100);
            }
        
        

Learning Summary

Download the Files

  • waveform_analysis
  • That’s all for now!