Skip to content

Instantly share code, notes, and snippets.

View Weathergadget's full-sized avatar

Weathergadget

View GitHub Profile
/* SPI Master Demo written by Robert Mollik, 2016
*
* This demo uses the SPI protocol on a Arduino Uno R3 / ATmega8 controller
*
* The demo sends out a request ID depending, whether a temperature or humidity signal shall be obtained from the slave. Both signals
* are datatype float, however get received as 4 bytes and need to be re-assembled.
*/
#define CS PC0 // Chip select pin, any vacant portpin can be used
@Weathergadget
Weathergadget / float_Disassemble_Reassemble.ino
Created May 22, 2016 02:23
Float_Disassemble_Reassemble
/*
*
* Sketch to show how to get the single bytes out of a float variable and resemble them to a new variable with the original Value.
* Can be used e. g. for the transfer via SPI, where only one byte at a time can be sent
*
* Robert Mollik 2016
*
* Created in the content of the development of my weather station and the need to tranfser values via SPI.
*
*/
/* USI SPI Slave Demo written by Robert Mollik, 2016
*
* This demo uses the SPI protocol with USI interface. This is necessary with with the smaller AVR controller since they don't
* a complete SPI functionality.
* Demo is written for the pinout of an Arduino Trinket and ATtiny85. Pins need to be modified if a different controller is used.
*
* The demo takes receives a request ID from the Master at the beginning of every communication. According to the request ID,
* it sends back either a temperature or a humidity values. Since both values are present in float, the 4 bytes of the float need
* to be send separately.
*/
For ($Num = 1; $Num -le 12: $Num ++)
{ #Do stuff
}
@Weathergadget
Weathergadget / Test.ino
Last active May 22, 2016 01:19
Testing
/* USI SPI Slave Demo written by Robert Mollik, 2016
*
* This demo uses the SPI protocol with USI interface. This is necessary with with the smaller AVR controller since they don't
* a complete SPI functionality.
* Demo is written for the pinout of an Arduino Trinket and ATtiny85. Pins need to be modified if a different controller is used.
*
* The demo takes receives a request ID from the Master at the beginning of every communication. According to the request ID,
* it sends back either a temperature or a humidity values. Since both values are present in float, the 4 bytes of the float need
* to be send separately.
*/