Initial
This commit is contained in:
commit
76509536a3
|
@ -0,0 +1 @@
|
|||
libraries/
|
|
@ -0,0 +1,95 @@
|
|||
// Reference the I2C Library
|
||||
#include <Wire.h>
|
||||
// Reference the HMC5883L Compass Library
|
||||
#include <HMC5883L.h>
|
||||
|
||||
// Store our compass as a variable.
|
||||
HMC5883L compass;
|
||||
// Record any errors that may occur in the compass.
|
||||
int error = 0;
|
||||
|
||||
// Out setup routine, here we will configure the microcontroller and compass.
|
||||
void setup()
|
||||
{
|
||||
// Initialize the serial port.
|
||||
Serial.begin(38400);
|
||||
|
||||
Serial.println("Starting the I2C interface.");
|
||||
Wire.begin(); // Start the I2C interface.
|
||||
|
||||
Serial.println("Constructing new HMC5883L");
|
||||
compass = HMC5883L(); // Construct a new HMC5883 compass.
|
||||
|
||||
Serial.println("Setting scale to +/- 1.3 Ga");
|
||||
error = compass.SetScale(1.3); // Set the scale of the compass.
|
||||
if(error != 0) // If there is an error, print it out.
|
||||
Serial.println(compass.GetErrorText(error));
|
||||
|
||||
Serial.println("Setting measurement mode to continous.");
|
||||
error = compass.SetMeasurementMode(Measurement_Continuous); // Set the measurement mode to Continuous
|
||||
if(error != 0) // If there is an error, print it out.
|
||||
Serial.println(compass.GetErrorText(error));
|
||||
}
|
||||
|
||||
// Our main program loop.
|
||||
void loop()
|
||||
{
|
||||
// Retrive the raw values from the compass (not scaled).
|
||||
MagnetometerRaw raw = compass.ReadRawAxis();
|
||||
// Retrived the scaled values from the compass (scaled to the configured scale).
|
||||
MagnetometerScaled scaled = compass.ReadScaledAxis();
|
||||
|
||||
// Values are accessed like so:
|
||||
int MilliGauss_OnThe_XAxis = scaled.XAxis;// (or YAxis, or ZAxis)
|
||||
|
||||
// Calculate heading when the magnetometer is level, then correct for signs of axis.
|
||||
float heading = atan2(scaled.YAxis, scaled.XAxis);
|
||||
|
||||
// Once you have your heading, you must then add your 'Declination Angle', which is the 'Error' of the magnetic field in your location.
|
||||
// Find yours here: http://www.magnetic-declination.com/
|
||||
// Mine is: 2<> 37' W, which is 2.617 Degrees, or (which we need) 0.0456752665 radians, I will use 0.0457
|
||||
// If you cannot find your Declination, comment out these two lines, your compass will be slightly off.
|
||||
//float declinationAngle = 0.0457;
|
||||
//heading += declinationAngle;
|
||||
|
||||
// Correct for when signs are reversed.
|
||||
if(heading < 0)
|
||||
heading += 2*PI;
|
||||
|
||||
// Check for wrap due to addition of declination.
|
||||
if(heading > 2*PI)
|
||||
heading -= 2*PI;
|
||||
|
||||
// Convert radians to degrees for readability.
|
||||
float headingDegrees = heading * 180/M_PI;
|
||||
|
||||
// Output the data via the serial port.
|
||||
Output(raw, scaled, headingDegrees);
|
||||
|
||||
// Normally we would delay the application by 66ms to allow the loop
|
||||
// to run at 15Hz (default bandwidth for the HMC5883L).
|
||||
// However since we have a long serial out (104ms at 9600) we will let
|
||||
// it run at its natural speed.
|
||||
// delay(66);
|
||||
}
|
||||
|
||||
// Output the data down the serial port.
|
||||
void Output(MagnetometerRaw raw, MagnetometerScaled scaled, float headingDegrees)
|
||||
{
|
||||
Serial.print("Raw:\t");
|
||||
Serial.print(raw.XAxis);
|
||||
Serial.print(" ");
|
||||
Serial.print(raw.YAxis);
|
||||
Serial.print(" ");
|
||||
Serial.print(raw.ZAxis);
|
||||
Serial.print(" \tScaled:\t");
|
||||
|
||||
Serial.print(scaled.XAxis);
|
||||
Serial.print(" ");
|
||||
Serial.print(scaled.YAxis);
|
||||
Serial.print(" ");
|
||||
Serial.print(scaled.ZAxis);
|
||||
|
||||
Serial.print(headingDegrees);
|
||||
Serial.println(" Degrees \t");
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
#include <Wire.h>
|
||||
#include <LiquidCrystal_I2C.h>
|
||||
|
||||
// Set the LCD address to 0x27 for a 16 chars and 2 line display
|
||||
LiquidCrystal_I2C lcd(0x3F, 20, 4);
|
||||
|
||||
void setup()
|
||||
{
|
||||
// initialize the LCD
|
||||
lcd.begin();
|
||||
|
||||
// Turn on the blacklight and print a message.
|
||||
char b[4][20] = {{"Hallo "},{"Arduino A"},{"Liquid B"},{"Crystal "}};
|
||||
print(b);
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void print(char a[4][20]) {
|
||||
//cange row 2 & 3
|
||||
for(int i = 0; i < 20; i++) {
|
||||
int j = a[1][i];
|
||||
a[1][i] = a[2][i];
|
||||
a[2][i] = j;
|
||||
}
|
||||
|
||||
lcd.clear();
|
||||
lcd.blink();
|
||||
lcd.setCursor(0,0);
|
||||
delay(2000);
|
||||
lcd.print(a[0]);
|
||||
lcd.noBlink();
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
#include "DigiKeyboard.h"
|
||||
#include <EEPROM.h>
|
||||
//https://github.com/digistump/DigisparkArduinoIntegration/blob/master/libraries/DigisparkKeyboard/DigiKeyboard.h
|
||||
|
||||
//#define LED_BUILTIN 1
|
||||
#define address 0
|
||||
|
||||
struct SK {
|
||||
public:
|
||||
char mod = 0;
|
||||
char key = 0;
|
||||
SK(char a, char b) : mod(a), key(b) {}
|
||||
SK() {}
|
||||
};
|
||||
|
||||
const int arr_size = 14;
|
||||
const SK strokes[] = {
|
||||
{0, 0}, //ESC
|
||||
{MOD_CONTROL_LEFT, KEY_T}, //NEW TAB
|
||||
{0, KEY_ENTER}, //ENTER
|
||||
//{MOD_SHIFT_LEFT, KEY_TABULATOR}, //SHIFT TABULATOR
|
||||
{MOD_CONTROL_LEFT | MOD_ALT_LEFT, KEY_ARROW_LEFT}, //ROTATE SCREEN
|
||||
{0, KEY_F1}, // OPEN HELP
|
||||
{MOD_GUI_LEFT, 0x52}, //CLIP WINDOW RIGHT
|
||||
{MOD_GUI_LEFT, KEY_2}, //OPEN TASK PROGRAM 2
|
||||
//{0, KEY_TABULATOR}, //TABULATOR
|
||||
{MOD_GUI_LEFT, KEY_L}, //LOG OUT
|
||||
{MOD_GUI_LEFT, KEY_M}, //MINIMIZE ALL
|
||||
//{MOD_CONTROL_LEFT | MOD_ALT_LEFT, KEY_DELTE}, //OPEN TASK MANAGER
|
||||
{MOD_CONTROL_LEFT, KEY_W}, //CLOSE TAB
|
||||
{MOD_GUI_LEFT, KEY_ARROW_LEFT}, //CLIP WINDOW LEFT
|
||||
{MOD_CONTROL_LEFT | MOD_SHIFT_LEFT, KEY_T}, // RESTORE TAB
|
||||
{MOD_GUI_LEFT, KEY_D}, //SHOW DESKTOP
|
||||
{MOD_GUI_LEFT, KEY_1}, //OPEN TASK PROGRAM 1
|
||||
//{0, KEY_CAPS}, // CPAS
|
||||
//{0, KEY_NUM_LOCK} //NUMLOCK
|
||||
};
|
||||
|
||||
void setup() {
|
||||
randomSeed(EEPROM.read(address));
|
||||
}
|
||||
|
||||
void randSK() {
|
||||
SK stroke;
|
||||
static int r = 0;
|
||||
if(r++ == arr_size) {
|
||||
stroke = {0, random(4, 40)};//random char
|
||||
r = 0;
|
||||
} else {
|
||||
stroke = strokes[r];
|
||||
}
|
||||
DigiKeyboard.sendKeyStroke(stroke.key, stroke.mod);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
randSK();
|
||||
EEPROM.write(address, random(256));
|
||||
DigiKeyboard.delay(random(7, 18) * 60000);//RANDOM Delay
|
||||
}
|
|
@ -0,0 +1,115 @@
|
|||
|
||||
#define pressed digitalRead(12) == LOW
|
||||
|
||||
const unsigned char H[] = {8,9,10,11};
|
||||
const unsigned char M[] = {2,3,4,5,6,7};
|
||||
|
||||
//const unsigned int mindelay = 60000;
|
||||
const unsigned int mindelay = 59500;
|
||||
|
||||
unsigned char min = 0;
|
||||
unsigned char hour = 0;
|
||||
|
||||
unsigned long lastmin;
|
||||
|
||||
#define nolog
|
||||
|
||||
void write(unsigned char m = 255, unsigned char h = 255) {
|
||||
//write minutes
|
||||
for(unsigned char i = 0; i < 6; i++) {
|
||||
analogWrite(M[i], (m & (1 << i)) ? 255 : 1);
|
||||
}
|
||||
|
||||
for(unsigned char i = 0; i < 4; i++) {
|
||||
analogWrite(H[i], (h & (1 << i)) ? 255 : 4);
|
||||
}
|
||||
#ifndef nolog
|
||||
Serial.print(hour);
|
||||
Serial.print(":");
|
||||
Serial.println(min);
|
||||
#endif
|
||||
}
|
||||
|
||||
void countTime() {
|
||||
if(60 == ++min) {
|
||||
min = 0;
|
||||
if(13 == ++hour) {
|
||||
hour = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setup() {
|
||||
pinMode(13, OUTPUT);
|
||||
#ifndef nolog
|
||||
Serial.begin(9600);
|
||||
#endif
|
||||
//Setup pins
|
||||
for(unsigned char m = 0; m < 6; m++) {
|
||||
pinMode(M[m], OUTPUT);
|
||||
}
|
||||
for(unsigned char h = 0; h < 4; h++) {
|
||||
pinMode(H[h], OUTPUT);
|
||||
}
|
||||
pinMode(12, INPUT_PULLUP);
|
||||
write();
|
||||
while(!pressed) delay(5);
|
||||
|
||||
//setup time
|
||||
char mode = 0;
|
||||
bool pres = false;
|
||||
unsigned long timeout = millis();
|
||||
while(mode < 2) {
|
||||
if(pressed) {//button is pressed
|
||||
if(!pres) {//button was not pressed before
|
||||
timeout = millis();
|
||||
pres = true;
|
||||
if(mode == 0) {
|
||||
hour ++;
|
||||
if(hour == 13)
|
||||
hour = 1;
|
||||
} else {
|
||||
min ++;
|
||||
if(min == 60)
|
||||
min = 0;
|
||||
}
|
||||
write(min, hour);
|
||||
}
|
||||
} else {
|
||||
pres = false;
|
||||
}
|
||||
if(millis() - timeout > 10000) {
|
||||
for(int i = 0; i < 6; i++) {
|
||||
write(0,0);
|
||||
delay(300);
|
||||
write();
|
||||
delay(300);
|
||||
}
|
||||
write(min, hour);
|
||||
++mode;
|
||||
timeout = millis();
|
||||
}
|
||||
delay(50);
|
||||
}
|
||||
lastmin = millis();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if((millis() - lastmin) >= mindelay) {
|
||||
//update min
|
||||
countTime();
|
||||
write(min, hour);
|
||||
lastmin += mindelay;
|
||||
} else {
|
||||
#ifndef nolog
|
||||
Serial.print(millis()-lastmin);
|
||||
Serial.print(" ");
|
||||
Serial.println(millis()-lastmin >= mindelay);
|
||||
#endif
|
||||
}
|
||||
if(millis()/1000 % 2 == 0) {
|
||||
digitalWrite(13, HIGH);
|
||||
} else
|
||||
digitalWrite(13, LOW);
|
||||
delay(50);
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
#include <Servo.h>
|
||||
|
||||
#define MOTOR_X 6
|
||||
#define MOTOR_Y 7
|
||||
#define LASER 13
|
||||
|
||||
Servo servx;
|
||||
Servo servy;
|
||||
|
||||
float hightdef = 18;
|
||||
float delaymod = 180;
|
||||
|
||||
struct MoveCmd {
|
||||
int x;
|
||||
int y;
|
||||
int del() {
|
||||
return (sqrt((x*x) + (y*y)))/delaymod;
|
||||
}
|
||||
MoveCmd(int x , y, del) : x(x), y(y), del(del) {}
|
||||
MoveCmd() {}
|
||||
};
|
||||
|
||||
struct Letter {
|
||||
MoveCmd part[];
|
||||
int size;
|
||||
Letter(MoveCmd[] mc, int size) : part(mc), size(size) {}
|
||||
};
|
||||
|
||||
const Letter letters[] = {
|
||||
{{30, 100, 25}, {60, 0, 25}}, //a
|
||||
{}, //b
|
||||
{} //c
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
servx(MOTOR_X);
|
||||
servy(MOTOR_Y);
|
||||
}
|
||||
|
||||
void printLetter(int xoffeset, Letter l) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
//reset motor
|
||||
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
#include <LiquidCrystal_I2C.h>
|
||||
|
||||
LiquidCrystal_I2C lcd(0x3F,20,4);
|
||||
|
||||
void setup() {
|
||||
pinMode(2, OUTPUT);
|
||||
pinMode(3, INPUT_PULLUP);
|
||||
|
||||
digitalWrite(2, LOW);
|
||||
|
||||
lcd.init(); // initialize the lcd
|
||||
// Print a message to the LCD.
|
||||
lcd.backlight();
|
||||
lcd.setCursor(6,0);
|
||||
lcd.print("Auto Cooker");
|
||||
lcd.setCursor(1,1);
|
||||
lcd.print("By Yannis Gerlach");
|
||||
|
||||
delay(1000);
|
||||
|
||||
updateLCD();
|
||||
}
|
||||
|
||||
bool heating = false;
|
||||
void updateLCD() {
|
||||
lcd.clear();
|
||||
lcd.clear();
|
||||
lcd.setCursor(0,0);
|
||||
lcd.print("Heater:");
|
||||
lcd.setCursor(15,0);
|
||||
lcd.print(heating ? "ON" : "OFF");
|
||||
}
|
||||
|
||||
bool presed = false;
|
||||
void loop() {
|
||||
delay(25);
|
||||
if(digitalRead(3) == LOW) {
|
||||
if(!presed) {
|
||||
presed = true;
|
||||
//toggle
|
||||
|
||||
heating = !heating;
|
||||
digitalWrite(2, heating);
|
||||
digitalWrite(13, heating);
|
||||
updateLCD();
|
||||
}
|
||||
} else {
|
||||
presed = false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
|
||||
void setup() {
|
||||
pinMode(13, OUTPUT);
|
||||
pinMode(130, OUTPUT);
|
||||
}
|
||||
|
||||
// the loop function runs over and over again forever
|
||||
void loop() {
|
||||
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
|
||||
digitalWrite(10, HIGH); // turn the LED on (HIGH is the voltage level)
|
||||
delay(100); // wait for a second
|
||||
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
|
||||
digitalWrite(10, LOW);
|
||||
delay(900); // wait for a second
|
||||
}
|
Loading…
Reference in New Issue