Weeks 12 Students A¶
Jed, Merrit, Ryan, Griffin, and Adam
Digital - Adam¶
I used a PIR Motion Sensor and connected it to an Arduino using this tutorial and wiring diagram. Here’s the code.
int PIRpin = 8; // The pin of Arduino connected to the PIR output
int PIRvalue = 0; // It specifies the status of PIR sensor
void setup() {
pinMode(PIRpin, INPUT);
// the output from the sensor is considered as input for Arduino
Serial.begin(9600);
}
void loop()
{
PIRvalue = digitalRead(PIRpin);
if (PIRvalue == HIGH)
{
Serial.println("Motion detected");
}
else
{
Serial.println("No motion detected");
delay(1000);
}
}
I then connected a multimeter to GND and the output pin, and when Griffin moved his hand in front of the sensor, we saw the digital signal.
Reading I2C signals - Merritt and Jed¶
Jed-I used a milled board with the Seeed Xiao RP2040 with a VL53l1X time of flight sensor and a breadboard to put oscilliscope probes between the SDA and SCL pins. I then uploaded an example code that wrote back the distances read from the time of flight sensor. I first only read the signals from the SDA pin which generate strange looking waveform. (PICTURE)
The next thing I did was connect the clock signal, the clock signal generated the same waveform with a slightly lower amplitude (PICTURE).
Merritt- I tried to use another sensor, because the waveforms that I was getting didn’t really make much sense to me. I used an accelerometer with an example code and the same wiring setup I had before and I got these waves, which looked more correct. The clock signal was a square wave that was pretty consistent in amplitude and consistent in frequency. The data wave was square waves that varied a little more.
The next thing that I decided to do was use the decode function on the osciloscope to show the data being transmitted. I selected the decode button, and set it to I2C with the correct clock signal. I did this and used the single button to capture some individual waves and see if I could get any that were transfering data. I was able to get a few that showed bits being written and recieve between the 2 devices.
Digital Signal With Oscilliscope- Ryan and Griffin¶
Ryan set up a circut with a button and an LED. He connected it to the XIAO, uploaded the basic button example code in the Arduino IDE to probe the signal level from both the LED according to the button.
He wired up a breaboard circuit, then put a jumper wire in channel one of the oscilliscope. The jumper wire in the oscilliscope went into the same connection in the breaboard as the LED to measure the voltage signals. When the button was pressed, the LED turned on, meaning there was a signal going into that part of the circuit. When Ryan and Griffin read the oscilliscope, they saw a change, but there was a noticeable amount of noise. Griffin turned the knob to the left, eliminating the sensitive reading, and seeing a pretty straight line change. They noticed that the level was slightly less than 5 volts, because they were using a 499 ohm resistor.
Code(Example in Arduino):
const int buttonPin = 6; // the number of the pushbutton pin
const int ledPin = 7; // the number of the LED pin
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}
void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
} else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
}
Here are notes on the key differences between digital and analog signal testing:
Waveform Representation: Digital signals are typically represented as a series of discrete voltage levels, while analog signals have a continuous range of voltage values. When displayed on an oscilloscope, digital signals appear as square or rectangular waveforms with distinct voltage levels, whereas analog signals appear as smooth and continuous waveforms.
Signal Accuracy: Analog signals can have an infinite number of voltage values within their range, allowing for precise representation of the signal. On the other hand, digital signals have discrete voltage levels, so the accuracy of the signal representation is limited by the number of bits used for digital encoding. Higher bit-depth results in better accuracy for digital signals.
Noise and Distortion: Analog signals are susceptible to noise and distortion, which can affect the shape and amplitude of the waveform. The noise and distortion can be observed on an oscilloscope as variations or fluctuations in the waveform. In contrast, digital signals are less prone to noise and distortion since they are based on discrete voltage levels. However, if there is significant noise present, it can cause errors in the digital signal, resulting in incorrect voltage levels.