Skip to content

Instantly share code, notes, and snippets.

View giljr's full-sized avatar
💭
Full Stack Developer with a degree in Computer Engineering.

Gilberto Oliveira Jr giljr

💭
Full Stack Developer with a degree in Computer Engineering.
View GitHub Profile
@giljr
giljr / _34_Sensor_ADXL345_Template.ino
Last active June 6, 2017 20:05
Although it is a pseudocode, this works! Page: https://goo.gl/rdL4uY
// ARDUINO six-steps PSEUDOCODE FOR 3-AXIS SENSORS ADXL345
#include <Wire.h>
/*
ADXL345 Datasheet: https://goo.gl/uOZc2b
Table 16. Register Map Address
Hex Dec Name Type Reset_Value Description
0x2D 45 POWER_CTL R/W 00000000 Power-saving features control.
(...)
0x32 50 DATAX0 R 00000000 X-Axis Data 0.
0x33 51 DATAX1 R 00000000 X-Axis Data 1.
#include <LiquidCrystal.h>
// LiquidCrystal (RS, E, d4, d5, d6, d7)
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // For standalone, non-shield, LCD
int ms1Pin = A0; // Stepstick MS0 to Arduino digital pin 9
int ms2Pin = A1; // Stepstock MS1 to Arduino digital pin 10
int ms3Pin = A2; // Stepstick MS2 to Arduino digital pin 11
int stepPin = A3; // Stepstick STEP pin to Arduino digital pin 12
int dirPin = A4; // Stepstick DIR pin to Arduino digital pin 13
@giljr
giljr / LCD16_2_Test_01.ino
Created June 17, 2017 20:56
See Webpage:
// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
#define DIR 2
#define STEP 3
#define BUTTON A0
#define M0 4
#define M1 5
#define M2 6
#define DIR 2
#define STEP 3
#define BUTTON A0
#define M0 4
#define M1 5
#define M2 6
int dPause = 100;
#define DIR 2
#define STEP 3
#define BATT A0
#define M0 4
#define M1 5
#define M2 6
#define _TRUE 1
#define _FALSE 0
#include <Wire.h> // I2C library
//-------- REGISTER MAP for ADXL345 chip -----//
#define ACC (0x53) // ADXL345 ACC address
#define POWER_CTL (0x2D) // Power-saving features control
#define DATA_FORMAT (0x31) // Data format control
#define BW_RATE (0x2C) // Data rate and power mode control
#define DATAX0 (0x32) // First address for axis x
#define A_TO_READ (6) // num of bytes we are going to read each time
// two bytes for each axis
@giljr
giljr / _100_J3_Solar_Tracket_Turret_v2.ino
Created October 17, 2017 21:20
J3 Solar Tracker Turret V1.0 / Visit : https://goo.gl/MtRcYe
#include <Servo.h> // include Servo library
Servo horizontal; // horizontal servo
int servoh = 90; // stand horizontal servo
Servo vertical; // vertical servo
int servov = 90; // stand vertical servo
// LDR pin connections
// name = analogpin;
int ldrlt = 0; //LDR top left
int ldrrt = 1; //LDR top rigt
int ldrld = 2; //LDR down left
@giljr
giljr / _35_Receiving_Serial_Data_11.ino
Last active October 29, 2017 22:59
J3BCP - Testing arrival bytes - See webpage: https://goo.gl/4zmgGK
/*
J3BCP Testing the bytes that come from Arduino.
Run this code on Arduino Pro Mini
see webpage: https://goo.gl/4zmgGK
*/
char data;
void setup() {
Serial.begin(9600);
#include <osa.h>
// Config TIMER2 @ 1 ms (FOSC = 8MHz)
/*
1.000 = P_cycleMachine * Prescaler * Postscale * (PR2 + 1)
1.000 = 0.5us * 4 * 10 * (PR2 + 1) //1:10 Postscaler
PR2 = 49 //Prescaler is 4
*/
#define T2CON_CONST 0B01001101 //Timer2 ON, Prescaler 1:4 e Postscale 1:10
#define PR2_CONST (49) //1us for FOSC