The schematic contains the following components:
I noticed that there is no voltage regulator in the schematic, Ben told me this is because the ATtiny runs on 5v. (The SAMD’s run on 3.3v)
I placed all the components in Kicad.
Then the difficult part begun. I connected the pins i knew how to connect.
For the rest of the connections went to Erwin’s site and looked at his schematic:
The following questions arose:
Why is there a resistor connected to 5v and pin 5 before the phototransistor?
How do i know which pins from the µC to connect to my components?
Since the photoresistor is operating like a switch we need to use a pull up or a pull down resistor.
As a comment in this example explains:
“If there were no link between pin and 0V (GND here), the input would be floating when button is not pressed, because of the very high input impedance. The resistor gives this link needed to make sure the input is at 0V in this case. A wire would not allow the pin to be HIGH when button pressed, as it would make a short between 5V and 0V”
But since we saw in the last answer that we need a pull up resistor before a button to prevent the input from floating, why isn’t there one before the switch on pin 7?
Again Ben to the rescue.
Ben told me that you can program the internal pull up resistor inside the µC instead of using a separate resistor. I knew arduino could do this.
The µC (in this example for the arduino, but also the ATtiny i’m using) has a lot of peripherals we can’t see. We can use the internal resistor as a pull up resistor by initializing the pin where the button is connected (lets say pin2) as pinMode(2,INPUT_PULLUP);
But why do we do this for the switch and not for the photoresistor?
Our guess is that this is because the resistance of the internal resistor is not so high, and fixed. This is fine for the button, but with the photoresistor we might need a higher resistance, and we want to be able to change this value.
But what does it all mean?
|VCC||Power input (ATtiny412 can operate 5v)|
|OUT (0 OUT, 1 OUT)||Logic output pin|
|IN (0 IN0, 0 IN1)||Logic input pin|
|SCK||SPI; Serial Clock, the line that carries the clock signal.|
|DAC||Digital to Analog converter (DAC), used for converting digital pulses to analog signals|
|TXD||Serial; Transmit data (connect to RXD of other device)|
|RXD||Serial; Receive data (connect to TXD of other device)|
|SDA||I2C; The line for the master and slave to send and receive data.|
|SCL||I2C; Serial Clock, the line that carries the clock signal.|
|UPDI||Pin for UPDI, interface for external programming and on-chip debugging of µC’s|
|CLK I||Clock In|
|GPIO (PA1, PA2, etc)||General Purpose Input/Output. PA1 corresponds to Pin 2 when coding)|
|CCL||Configurable Custom Logic|
Other important things:
|Flash memory||4096 bytes|
Now i should be able to connect the rest of my pins.
I used labels for the Vcc and GND to make the schematic more tidy.