November 3, 2020

Pcomp3 - Transistors

Transistors are used in many aspects of our lives. Here we mainly introduce more information about transistors…


A transistor is a semiconductor device used to amplify or switch electronic signals and electrical power. It is composed of semiconductor material usually with at least three terminals for connection to an external circuit. A voltage or current applied to one pair of the transistor’s terminals controls the current through another pair of terminals. Because the controlled (output) power can be higher than the controlling (input) power, a transistor can amplify a signal. Today, some transistors are packaged individually, but many more are found embedded in integrated circuits.


1.PWM

We are going to use PWM to fade an LED.

This is a very basic case, I can understand how to control the output LEDs through digital signals.



You can see more details:

led
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
int brightness = 0;    // how bright the LED is
int fadeAmount = 5; // how many points to fade the LED by

// the setup routine runs once when you press reset:
void setup() {
// declare pin 9 to be an output:
pinMode(led, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
// set the brightness of pin 9:
analogWrite(led, brightness);

// change the brightness for next time through the loop:
brightness = brightness + fadeAmount;

// reverse the direction of the fading at the ends of the fade:
if (brightness <= 0 || brightness >= 255) {
fadeAmount = -fadeAmount;
}
// wait for 30 milliseconds to see the dimming effect
delay(30);
}

2.Voltage Dividers

Hook up the circuit in the slides with the light dependent resistor.

Sending data through digital and analog signals to control RGB values of the LED, this method allows us to control the output more precisely.

In this case, I tried to adjust the value through three photosensitive sensors, you can try to adjust them to light up the LED.



Bellow is my codes:

int greenLEDPin
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const int redLEDPin = 11;
const int blueLEDPin = 10;
const int redSensorPin = A0;
const int greenSensorPin = A1;
const int blueSensorPin = A2;
int redValue = 0;
int greenValue = 0;
int blueValue = 0;
int redSensorValue = 0;
int greenSensorValue = 0;
int blueSensorValue = 0;
void setup() {
Serial.begin(9600);
pinMode(greenLEDPin,OUTPUT);
pinMode(redLEDPin,OUTPUT);
pinMode(blueLEDPin,OUTPUT);
}
void loop() {
redSensorValue = analogRead(redSensorPin);
delay(5);
greenSensorValue = analogRead(greenSensorPin);
delay(5);
blueSensorValue = analogRead(blueSensorPin);
Serial.print("Raw Sensor Values \t Red: ");
Serial.print(redSensorValue);
Serial.print("\t Green: ");
Serial.print(greenSensorValue);
Serial.print("\t Blue: ");
Serial.println(blueSensorValue);
redValue = redSensorValue/4;
greenValue = greenSensorValue/4;
blueValue = blueSensorValue/4;
Serial.print("Mapped Sensor Value \t Red: ");
Serial.print(redValue);
Serial.print("\t Green: ");
Serial.print(greenValue);
Serial.print("\t Blue: ");
Serial.println(blueValue);
analogWrite(redLEDPin, redValue);
analogWrite(greenLEDPin, greenValue);
analogWrite(blueLEDPin, blueValue);
}

3.Dark detecting Circuit

Making dark detecting LED (From Circuit diagram to breadboard) Build this project to better understand transistors.



4.Feedback systems

Systems which feedback on themselves often feel more alive to us than static systems which only output data. Try to change the value of the light-dependent resistor.



About this Post

This post is written by Siqi Shu, licensed under CC BY-NC 4.0.