Commit a4b37dc5 authored by Katie Isard's avatar Katie Isard
Browse files

week14 golobal board hello

parent 171720d5
Pipeline #241914 passed with stage
in 30 seconds
/*
TinyWireM.h - a wrapper(+) class for TWI/I2C Master library for the ATtiny on Arduino
1/21/2011 BroHogan - brohoganx10 at gmail dot com
Thanks to 'jkl' for the gcc version of Atmel's USI_TWI_Master code
http://www.cs.cmu.edu/~dst/ARTSI/Create/PC%20Comm/
I added Atmel's original Device dependant defines section back into USI_TWI_Master.h
NOTE! - It's very important to use pullups on the SDA & SCL lines! More so than with the Wire lib.
USAGE is modeled after the standard Wire library . . .
Put in setup():
TinyWireM.begin(){ // initialize I2C lib
To Send:
TinyWireM.beginTransmission(uint8_t slaveAddr){ // setup slave's address (7 bit address - same as Wire)
TinyWireM.send(uint8_t data){ // buffer up bytes to send - can be called multiple times
someByte = TinyWireM.endTransmission(){ // actually send the bytes in the buffer
// returns (optional) 0 = sucess or see USI_TWI_Master.h for error codes
To Receive:
someByte = TinyWireM.requestFrom(uint8_t slaveAddr, uint8_t numBytes){ // reads 'numBytes' from slave's address
// (usage optional) returns 0= success or see USI_TWI_Master.h for error codes
someByte = TinyWireM.receive(){ // returns the next byte in the received buffer - called multiple times
someByte = TinyWireM.available(){ // returns the number of unread bytes in the received buffer
TODO: (by others!)
- merge this class with TinyWireS for master & slave support in one library
This library is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation; either version 2.1 of the License, or any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
*/
#ifndef TinyWireM_h
#define TinyWireM_h
#include <inttypes.h>
#define USI_SEND 0 // indicates sending to TWI
#define USI_RCVE 1 // indicates receiving from TWI
#define USI_BUF_SIZE 16 // bytes in message buffer
class USI_TWI
{
private:
static uint8_t USI_Buf[]; // holds I2C send and receive data
static uint8_t USI_BufIdx; // current number of bytes in the send buff
static uint8_t USI_LastRead; // number of bytes read so far
static uint8_t USI_BytesAvail; // number of bytes requested but not read
public:
USI_TWI();
void begin();
void beginTransmission(uint8_t);
void send(uint8_t);
uint8_t endTransmission();
uint8_t requestFrom(uint8_t, uint8_t);
uint8_t receive();
uint8_t available();
};
extern USI_TWI TinyWireM;
#endif
// Wire Master Reader
// by Nicholas Zambetti <http://www.zambetti.com>
// Demonstrates use of the Wire library
// Reads data from an I2C/TWI slave device
// Refer to the "Wire Slave Sender" example for use with this
// Created 29 March 2006
// This example code is in the public domain.
#include <Wire.h>
void setup() {
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(9600); // start serial for output
}
void loop() {
Wire.requestFrom(8, 6); // request 6 bytes from slave device #8
while (Wire.available()) { // slave may send less than requested
char c = Wire.read(); // receive a byte as character
Serial.print(c); // print the character
}
delay(500);
}
// Wire Master Writer
// by Nicholas Zambetti <http://www.zambetti.com>
// Demonstrates use of the Wire library
// Writes data to an I2C/TWI slave device
// Refer to the "Wire Slave Receiver" example for use with this
// Created 29 March 2006
// This example code is in the public domain.
#include <Wire.h>
void setup() {
Wire.begin(); // join i2c bus (address optional for master)
}
byte x = 0;
void loop() {
Wire.beginTransmission(8); // transmit to device #8
Wire.write("x is "); // sends five bytes
Wire.write(x); // sends one byte
Wire.endTransmission(); // stop transmitting
x++;
delay(500);
}
......@@ -343,7 +343,33 @@
<h3>Global evaluation</h3>
<p>As pointed out I have used Luiz board therefore means I needed to redo this week with a board I had designed myself, so I went back and used my board from <a href="http://fabacademy.org/2021/labs/plusx/students/katie-isard/week11.html">week11</a> which I didn't use because the sketch was too large. But it was suggested that I use 'TinyWireM.h' onto my ATtiny44 and then use an Arduino uno and put on it 'Wire.h'.</p>
<p>As pointed out I have used Luiz board therefore means I needed to redo this week with a board I had designed myself, so I used my board for my <a href="http://fabacademy.org/2021/labs/plusx/students/katie-isard/fp.html">final project</a> which was an edited version of Luiz board. I did have to hack a few pieces onto the pins that I needed as they were two of the pins that were not brought out as I didn't think I was going to need them in the future. </p>
<p>I got a male to male wire cut it in half, stripped the ends and soldered them to the correct pins.</p>
<p>
<img src="images/week14/pinouts_final.png" height="500" alt="pinouts_final">
<img src="images/week14/wk14_final_hacked02.jpeg" height="500" alt="wk14_final_hacked02">
</p>
<p>Here are the two boards together, it is a little more manic than the one above as my 'final board' I have to use a programmer to get anything to go onto it which is a pain. But this did work, I did end up having to change the code from above as this didn't work. Please see the .ino file below to see the correct sketch for this outcome as seen below.</p>
<p>
<img src="images/week14/wk14_boards.jpeg" height="500" alt="wk14_boards">
<img src="images/week14/wk14_networking.jpeg" height="500" alt="wk14_networking">
</p>
<ul>
<li><a href="files/week14/master_reader/master_reader.ino">master_reader .ino</a> </li>
<li><a href="files/week14/master_writer/master_writer.ino">master_writer .ino</a> </li>
</ul>
<p>I am so happy this worked as at the beginning I kept getting an error saying that it couldn't find the correct serial port, I resoldered the wires which then worked as seen! woohoo.</p>
<p>
<img src="images/week14/error.jpeg" height="500" alt="error">
</p>
......@@ -356,6 +382,8 @@
<li> <a href="files/week15/outline.png.zip">my outline .png</a></li>
<li> <a href="files/week14/luiz_outline_new.ai.zip">illistrator file outline .ai</a></li>
<li> <a href="files/week14/luiz_traces_new.ai.zip">illistrator file traces .ai</a></li>
<li> <a href="files/final/final_boar_outline.png.zip">final board outline .png</a></li>
<li> <a href="files/final/final_boar_traces.png.zip">final board traces .png</a></li>
</ul>
<h4>Other Pages:</h4>
......
Supports Markdown
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