Commit f70f5ade authored by Philip Hozier's avatar Philip Hozier
Browse files

week8 - finish 3/5

parent 33d2068b
Pipeline #228257 passed with stages
in 21 seconds
......@@ -388,7 +388,7 @@ The last spiral was to get an analogue input to affect the brightness of the LED
}
void loop() {
i f (digitalRead(BUTTON_pin) == LOW) {
if (digitalRead(BUTTON_pin) == LOW) {
AnalogValue = analogRead(ANALOG_pin);
DutyCycle = map(AnalogValue, 0, 1023, 0, 99);
......@@ -548,6 +548,40 @@ Where 'cu.usbserial-D30A3T7Y' is the port your FTDI is using.
![Individual Assignment](../week8/wk8-serial-output.jpg "Serial output")
*UPDATE*
I made an FTDI and tried out the program and instantly got some serial output! check out the morse code serial output image above.
![Temporary setup for testing](../week8/temp-setup.jpg "Temporary testing setup")
**Analogue Output**
With some serial feedback possible it was time to investigate why the phototransistor wasn't performing as expected. A quick look at the output (with my phone's LED light as a light source) and the values coming out were between 580 and 600 depending on the light shining on the phototransistor. This wasn't exactly a big difference between dark and light.
I then tried it in bright daylight, and although the numbers were higher, the difference between the sensor covered and uncovered were still the same. To make this work a lot of tricky programming would be needed mapping the values to
something more useful. From other students I had already heard what the real problem was so I wasn't going to spend time doing this.
The reality was that the phototransistor was actually an Infra-red photo transistor and had been accidentally ordered instead of the normal ones. The values we expected to see, 0 - 1023, were never going to be reached under normal light conditions.
Should it have worked, I would've used this code to test:
// Program to dim LED depending on phototransistor
#define LED_pin 0
#define Analogue_pin A0
int analogueValue = 0;
void setup() {
// put your setup code here, to run once:
pinMode(LED_pin,OUTPUT);
pinMode(Analogue_pin, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
analogueValue = analogRead(Analogue_pin);
analogueValue = map(analogueValue,0,1023,1,255);
digitalWrite( LED_pin, analogueValue);
}
---
## Further Development
---
......@@ -587,11 +621,9 @@ Google searches came up with almost nothing, and then I realised, it was upside
When trying the serial communication test program I came up against these problems. I had borrowed a commercially available FTDI board to test my programming (while I would re-make an Fablab FTDI at another time). This had 'male' serial header pins so wouldn't fit directly onto my 'Hello' board. I looked at the 'Hello' board schematic and connected my 1 and 3 pins to the GND and Vcc of the FTDI . I was confident of the Serial programming I had done , but whilst wondering why I was receiving no serial communication from the board, I realised that the FTDI should have the Tx and Rx pins connect to have a fighting chance of working. Back to the schematic and connected to pins 4 + 5. The ```Serial.swap()``` to activate the alternative function needed on these pins for my board was in the program. But that still didn't work. I tried checking that the different boards were recognised by the System Profile and scanned the USB ports in Terminal like above, and both boards were there as expected. I must be missing something simple but I don't know were to look. I 'll wait till i've made my own FTDI to take the 'non-standard' temporary FTDI board out of the equation to test again.
*UPDATE*
I made an FTDI and tried out the program and instantly got some serial output! check out the morse code serial output image above.
**The phototransistor**
![Temporary setup for testing](../week8/temp-setup.jpg "Temporary testing setup")
The phototransistor was actually an Infra-red phototransistor. So without those lighting conditions nothing useful was going to come from that sensor.
---
## CONCLUSION
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment