Thursday, July 20, 2023

Solar Super Capacitor Resin Creation with Attiny85

 


watch whole diy video on youtube:https://youtu.be/81VuIfaRIzI


Code below for this solar supercapacitor resin creation


#include <avr/sleep.h>

#include <avr/wdt.h> 


#ifndef cbi

#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))

#endif

#ifndef sbi

#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))

#endif 


volatile boolean f_wdt = 1; 

int pinLed0 = PB0;

int pinLed1 = PB1;

int pinLed2 = PB2;

int pinLDR = A2;



void setup() 

  {

    pinMode(pinLed0, OUTPUT);

    pinMode(pinLed1, OUTPUT);

    pinMode(pinLed2, OUTPUT);

    pinMode(pinLDR, INPUT_PULLUP);    setup_watchdog(7);// 0=16ms, 1=32ms,2=64ms,3=128ms,4=250ms,5=500ms

                      // 6=1sec, 7=2 sec, 8=4 sec, 9= 8sec

  } 


void loop()

  {

    if (f_wdt == 1)

    {

      f_wdt = 0;

      if(digitalRead(pinLDR) == HIGH)

      {

    

          digitalWrite(pinLed0, HIGH);

        delay(100);

        digitalWrite(pinLed0, LOW);

        delay(100);

        digitalWrite(pinLed1, HIGH);

        delay(100);

        digitalWrite(pinLed1, LOW);

        delay(100);

         digitalWrite(pinLed2, HIGH);

        delay(100);

        digitalWrite(pinLed2, LOW);

         delay(10000);

      

        

        

        

        

         }



      

      system_sleep();

    }

  }



  void system_sleep()

  {

    cbi(ADCSRA, ADEN);

    set_sleep_mode(SLEEP_MODE_PWR_DOWN);

    sleep_enable();

    sleep_mode();

    sleep_disable();

    sbi(ADCSRA, ADEN);

  }



  void setup_watchdog(int ii)

  {

    byte bb;

    int ww;

    if (ii > 9 ) ii = 9;

    bb = ii & 7;

    if (ii > 7) bb |= (1 << 5);

    bb |= (1 << WDCE);

    ww = bb;

    MCUSR &= ~(1 << WDRF);

    WDTCR |= (1 << WDCE) | (1 << WDE);

    WDTCR = bb;

    WDTCR |= _BV(WDIE);

  }

  ISR(WDT_vect)

  {

    f_wdt = 1;

  }


end of code



Monday, June 12, 2023

Arduino Metal detector

 

On Arduino pins A2,A4 and A5 connect leds for indicating,on D12 buzzer and D5 goes to oscilator.

here is code for Arduino:

--------------------------------------------------------------------------------

#include <FreqCount.h>


//the baseline frequency of the main search coil

unsigned long baseLine = 10;


//Pins red, green and blue LEDs are attached to.

const int bluePin = A2;

const int greenPin = A4;

const int redPin = A5;

const int buzzerPin = 12;



void setup() {

  //set our LED pins as outputs

  pinMode(redPin,OUTPUT);

  pinMode(greenPin,OUTPUT);

  pinMode(bluePin,OUTPUT);

  pinMode(buzzerPin,OUTPUT);

  //Flash a sequence to test the LEDs and show we are starting up  

  digitalWrite(redPin,HIGH);

  delay(200);

  silence();

  digitalWrite(greenPin,HIGH);

  delay(200);

  silence();

  digitalWrite(bluePin,HIGH);

  delay(200);

  silence();


  //Read out baseline frequency count, 100ms intervals

  FreqCount.begin(100);

  while(!FreqCount.available())

  {

    delay(10);

  }

  baseLine = FreqCount.read();


  if(baseLine > 10000)

  {

    //Green, we started up OK

    digitalWrite(greenPin,HIGH);  

  }

  else

  {

    //Red, something went wrong, we didn't get a sensible count

    digitalWrite(redPin,HIGH);

  }

  delay(1000);


  silence();

}



void loop() {

  //no sample ready yet, exit.

  if (!FreqCount.available()) {

    return;

  }

  //Read how many pulses in 100 milliseconds

  unsigned long count = FreqCount.read();

  

  long difference =  baseLine - count;

  difference = abs(difference);

  

  //Difference is large, turn on the RED led

  if(difference > 5)

  {

    digitalWrite(greenPin,LOW);

    digitalWrite(bluePin,LOW);

    digitalWrite(redPin,HIGH);

    digitalWrite(buzzerPin,HIGH);

  }

  else if(difference > 2)  //medium difference, green

  {

    digitalWrite(greenPin,HIGH);

    digitalWrite(bluePin,LOW);

    digitalWrite(redPin,LOW);

    digitalWrite(buzzerPin,HIGH);

  }

  else if(difference > 1) //small difference, blue.

  {

    digitalWrite(greenPin,LOW);

    digitalWrite(bluePin,HIGH);

    digitalWrite(redPin,LOW);

    digitalWrite(buzzerPin,HIGH);

  }

  else

  {

    silence(); //no difference, turn off all LEDs

    digitalWrite(buzzerPin,LOW);

  }


  //Auto-adjust our baseline

  if(count > baseLine)

  {

    baseLine +=1;

  }

  else if (count < baseLine)

  {

     baseLine -= 1;

  }

}


  //Turn off all output pins

  void silence()

  {

    digitalWrite(redPin,LOW);

    digitalWrite(greenPin,LOW);

    digitalWrite(bluePin,LOW);

  }


Mine metal detector finished


Full youtube video How to make:

https://youtu.be/syDSZNArNjY

Its not mine project the author is this check out:https://siliconjunction.wordpress.com/2019/02/14/a-simple-arduino-metal-detector/

Friday, April 14, 2023

Led flux capacitor with Attiny85

 


Code below for Attiny85 flux capacitor effect:


void setup() // setup all pins as OUTPUTS to drive current for 

{            // the LEDs.

  pinMode(4, OUTPUT);

  pinMode(3, OUTPUT);

  pinMode(2, OUTPUT);

  pinMode(1, OUTPUT);

  pinMode(0, OUTPUT);

}


void loop(){

  digitalWrite(4, HIGH);

  delay(60);           

  digitalWrite(4, LOW); 

  delay(60);           

  digitalWrite(3, HIGH);

  delay(60);            

  digitalWrite(3, LOW); 

  delay(60);            

  digitalWrite(2, HIGH); 

  delay(60);           

  digitalWrite(2, LOW); 

    delay(60);  

  digitalWrite(1, HIGH); 

    delay(60);  

  digitalWrite(1, LOW); 

    delay(60);  

  digitalWrite(0, HIGH);

    delay(60);   

  digitalWrite(0, LOW);  

  delay(700);            // 500 ms delay

}

Sunday, April 2, 2023

Attiny85 oled 64x32 hello world

 



code for arduino oled screen 64x32 :


Dont forget to install library ssd1306 mininal and Tinywire

----------------------------------------------------------------------------

#include "SSD1306_minimal.h"

#include <avr/pgmspace.h>


#define DEG "\xa7" "C"


SSD1306_Mini oled; // Declare the OLED object


void splash() {

 oled.startScreen();

 oled.clear(); // Clears the display


 oled.cursorTo(32, 4); // x:0, y:0

 oled.printString("Hello");

 delay(2000);

 oled.cursorTo(32, 5); // x:0, y:23

 oled.printString("ATtiny85");

delay(2000);

 oled.cursorTo(32, 6); // x:0, y:23

 oled.printString("Hacktuber");

delay(2000);

 oled.cursorTo(32, 7); // x:0, y:23

 oled.printString("YouTube");

 delay(2000);

}


void setup() {

 oled.init(0x3C); // Initializes the display to the specified address

 oled.clear(); // Clears the display

 delay(1000); // Delay for 1 second

 splash(); // Write something to the display (refer to the splash() method

}


void loop() {

}

Friday, March 17, 2023

Dino weather station using Arduino

 Just copy the code:


#include <Wire.h>

#include <SPI.h>

#include <Adafruit_Sensor.h>

#include <Adafruit_BME280.h>

#include <Adafruit_GFX.h>

#include <Adafruit_SSD1306.h>

/*#include <SPI.h>

#define BME_SCK 18

#define BME_MISO 19

#define BME_MOSI 23

#define BME_CS 5*/


#define SEALEVELPRESSURE_HPA (1013.25)


Adafruit_BME280 bme; // I2C

//Adafruit_BME280 bme(BME_CS); // hardware SPI

//Adafruit_BME280 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK); // software SPI


Adafruit_SSD1306 display = Adafruit_SSD1306(128, 32, &Wire);

unsigned long delayTime;


void setup() {

  Serial.begin(9600);

  Serial.println(F("BME280 test"));

   

  // by default, we'll generate the high voltage from the 3.3v line internally! (neat!)

  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3C (for the 128x64)

   // init done

  display.display();

  delay(100);

  display.clearDisplay();

  display.display();

  display.setTextSize(1.2);

  display.setTextColor(WHITE);

  

  bool status;

  // default settings

  // (you can also pass in a Wire library object like &Wire2)

  status = bme.begin(0x76);  

  if (!status) {

    Serial.println("Could not find a valid BME280 sensor, check wiring!");

    while (1);

  }


  Serial.println("-- Default Test --");

  delayTime = 1000;


  Serial.println();

}



void loop() { 

  

  display.setCursor(0,0);

  display.clearDisplay();

  

  Serial.print("Temperature = "); Serial.print(bme.readTemperature()); Serial.println(" *C");

  display.print("Temperature: "); display.print(bme.readTemperature()); display.println(" *C");


  Serial.print("Pressure = "); Serial.print(bme.readPressure() / 100.0F); Serial.println(" hPa");

  display.print("Pressure: "); display.print(bme.readPressure() / 100.0F); display.println(" hPa");


  Serial.print("Humidity = "); Serial.print(bme.readHumidity()); Serial.println(" %");

  display.print("Humidity: "); display.print(bme.readHumidity()); display.println(" %");


  Serial.println();

  display.display();

  delay(1000);

}




Monday, March 30, 2020

Arduino temperature and humidity meter

Arduino based temperature and humidity meter using 8x8 led dot matrix,DHT11 sensor and arduino nano board,whole setup cost 4.5$


here is the code:

#include <MaxMatrix.h> 
#include <avr/pgmspace.h>
#include <stdlib.h>
#include "DHT.h" 
#define DHTPIN 7     // Pin al que esta conectado el DHT11
#define DHTTYPE DHT11   // Tipo de sensor en este caso DHT11
DHT dht(DHTPIN, DHTTYPE);

PROGMEM unsigned char const CH[] = {
3, 8, B00000000, B00000000, B00000000, B00000000, B00000000, // space
1, 8, B01011111, B00000000, B00000000, B00000000, B00000000, // !
3, 8, B00000011, B00000000, B00000011, B00000000, B00000000, // "
5, 8, B00010100, B00111110, B00010100, B00111110, B00010100, // #
4, 8, B00100100, B01101010, B00101011, B00010010, B00000000, // $
5, 8, B01100011, B00010011, B00001000, B01100100, B01100011, // %
5, 8, B00110110, B01001001, B01010110, B00100000, B01010000, // &
1, 8, B00000011, B00000000, B00000000, B00000000, B00000000, // '
3, 8, B00011100, B00100010, B01000001, B00000000, B00000000, // (
3, 8, B01000001, B00100010, B00011100, B00000000, B00000000, // )
5, 8, B00101000, B00011000, B00001110, B00011000, B00101000, // *
5, 8, B00001000, B00001000, B00111110, B00001000, B00001000, // +
2, 8, B10110000, B01110000, B00000000, B00000000, B00000000, // ,
4, 8, B00001000, B00001000, B00001000, B00001000, B00000000, // -
2, 8, B01100000, B01100000, B00000000, B00000000, B00000000, // .
4, 8, B01100000, B00011000, B00000110, B00000001, B00000000, // /
4, 8, B00111110, B01000001, B01000001, B00111110, B00000000, // 0
3, 8, B01000010, B01111111, B01000000, B00000000, B00000000, // 1
4, 8, B01100010, B01010001, B01001001, B01000110, B00000000, // 2
4, 8, B00100010, B01000001, B01001001, B00110110, B00000000, // 3
4, 8, B00011000, B00010100, B00010010, B01111111, B00000000, // 4
4, 8, B00100111, B01000101, B01000101, B00111001, B00000000, // 5
4, 8, B00111110, B01001001, B01001001, B00110000, B00000000, // 6
4, 8, B01100001, B00010001, B00001001, B00000111, B00000000, // 7
4, 8, B00110110, B01001001, B01001001, B00110110, B00000000, // 8
4, 8, B00000110, B01001001, B01001001, B00111110, B00000000, // 9
2, 8, B01010000, B00000000, B00000000, B00000000, B00000000, // :
2, 8, B10000000, B01010000, B00000000, B00000000, B00000000, // ;
3, 8, B00010000, B00101000, B01000100, B00000000, B00000000, // <
3, 8, B00010100, B00010100, B00010100, B00000000, B00000000, // =
3, 8, B01000100, B00101000, B00010000, B00000000, B00000000, // >
4, 8, B00000010, B01011001, B00001001, B00000110, B00000000, // ?
5, 8, B00111110, B01001001, B01010101, B01011101, B00001110, // @
4, 8, B01111110, B00010001, B00010001, B01111110, B00000000, // A
4, 8, B01111111, B01001001, B01001001, B00110110, B00000000, // B
4, 8, B00111110, B01000001, B01000001, B00100010, B00000000, // C
4, 8, B01111111, B01000001, B01000001, B00111110, B00000000, // D
4, 8, B01111111, B01001001, B01001001, B01000001, B00000000, // E
4, 8, B01111111, B00001001, B00001001, B00000001, B00000000, // F
4, 8, B00111110, B01000001, B01001001, B01111010, B00000000, // G
4, 8, B01111111, B00001000, B00001000, B01111111, B00000000, // H
3, 8, B01000001, B01111111, B01000001, B00000000, B00000000, // I
4, 8, B00110000, B01000000, B01000001, B00111111, B00000000, // J
4, 8, B01111111, B00001000, B00010100, B01100011, B00000000, // K
4, 8, B01111111, B01000000, B01000000, B01000000, B00000000, // L
5, 8, B01111111, B00000010, B00001100, B00000010, B01111111, // M
5, 8, B01111111, B00000100, B00001000, B00010000, B01111111, // N
4, 8, B00111110, B01000001, B01000001, B00111110, B00000000, // O
4, 8, B01111111, B00001001, B00001001, B00000110, B00000000, // P
4, 8, B00111110, B01000001, B01000001, B10111110, B00000000, // Q
4, 8, B01111111, B00001001, B00001001, B01110110, B00000000, // R
4, 8, B01000110, B01001001, B01001001, B00110010, B00000000, // S
5, 8, B00000001, B00000001, B01111111, B00000001, B00000001, // T
4, 8, B00111111, B01000000, B01000000, B00111111, B00000000, // U
5, 8, B00001111, B00110000, B01000000, B00110000, B00001111, // V
5, 8, B00111111, B01000000, B00111000, B01000000, B00111111, // W
5, 8, B01100011, B00010100, B00001000, B00010100, B01100011, // X
5, 8, B00000111, B00001000, B01110000, B00001000, B00000111, // Y
4, 8, B01100001, B01010001, B01001001, B01000111, B00000000, // Z
2, 8, B01111111, B01000001, B00000000, B00000000, B00000000, // [
4, 8, B00000001, B00000110, B00011000, B01100000, B00000000, // \ backslash
2, 8, B01000001, B01111111, B00000000, B00000000, B00000000, // ]
3, 8, B00000010, B00000001, B00000010, B00000000, B00000000, // hat
4, 8, B01000000, B01000000, B01000000, B01000000, B00000000, // _
2, 8, B00000001, B00000010, B00000000, B00000000, B00000000, // `
4, 8, B00100000, B01010100, B01010100, B01111000, B00000000, // a
4, 8, B01111111, B01000100, B01000100, B00111000, B00000000, // b
4, 8, B00111000, B01000100, B01000100, B00101000, B00000000, // c
4, 8, B00111000, B01000100, B01000100, B01111111, B00000000, // d
4, 8, B00111000, B01010100, B01010100, B00011000, B00000000, // e
3, 8, B00000100, B01111110, B00000101, B00000000, B00000000, // f
4, 8, B10011000, B10100100, B10100100, B01111000, B00000000, // g
4, 8, B01111111, B00000100, B00000100, B01111000, B00000000, // h
3, 8, B01000100, B01111101, B01000000, B00000000, B00000000, // i
4, 8, B01000000, B10000000, B10000100, B01111101, B00000000, // j
4, 8, B01111111, B00010000, B00101000, B01000100, B00000000, // k
3, 8, B01000001, B01111111, B01000000, B00000000, B00000000, // l
5, 8, B01111100, B00000100, B01111100, B00000100, B01111000, // m
4, 8, B01111100, B00000100, B00000100, B01111000, B00000000, // n
4, 8, B00111000, B01000100, B01000100, B00111000, B00000000, // o
4, 8, B11111100, B00100100, B00100100, B00011000, B00000000, // p
4, 8, B00011000, B00100100, B00100100, B11111100, B00000000, // q
4, 8, B01111100, B00001000, B00000100, B00000100, B00000000, // r
4, 8, B01001000, B01010100, B01010100, B00100100, B00000000, // s
3, 8, B00000100, B00111111, B01000100, B00000000, B00000000, // t
4, 8, B00111100, B01000000, B01000000, B01111100, B00000000, // u
5, 8, B00011100, B00100000, B01000000, B00100000, B00011100, // v
5, 8, B00111100, B01000000, B00111100, B01000000, B00111100, // w
5, 8, B01000100, B00101000, B00010000, B00101000, B01000100, // x
4, 8, B10011100, B10100000, B10100000, B01111100, B00000000, // y
3, 8, B01100100, B01010100, B01001100, B00000000, B00000000, // z
3, 8, B00001000, B00110110, B01000001, B00000000, B00000000, // {
1, 8, B01111111, B00000000, B00000000, B00000000, B00000000, // |
3, 8, B01000001, B00110110, B00001000, B00000000, B00000000, // }
4, 8, B00001000, B00000100, B00001000, B00000100, B00000000, // ~
};

int data = 12;    // DIN pin del módulo MAX7219
int load = 10;    // CS pin del módulo MAX7219
int clock = 11;  // CLK pin del módulo MAX7219
int maxInUse = 1;    // Cuantos módulos MAX7219 se estan usando
MaxMatrix m(data, load, clock, maxInUse);
byte buffer[10];

void setup(){
  pinMode(2,INPUT); // Entrada de Botón
  m.init(); 
  m.setIntensity(15); // Intensidad luminosa de la matriz
  Serial.begin(3600);
  Serial.println("Iniciando sensor");
  dht.begin();
}

void loop(){
  
  printStringWithShift("  ", 75);
  int t = dht.readTemperature();
  char temp[4];
  itoa(t,temp,10); 
  Serial.println(temp);
  printStringWithShift("T ", 75);
  printStringWithShift(temp, 75);
  printStringWithShift("C ", 75);
  delay(100);
  m.shiftLeft(false, true);
  int h = dht.readHumidity();
  char hum[4];
  itoa(h,hum,10); 
  Serial.println(hum);
  printStringWithShift(" H ", 75);
  printStringWithShift(hum, 75);
  printStringWithShift("% ", 75);
  delay(100);
  m.shiftLeft(false, true);
  }


void printCharWithShift(char c, int shift_speed){
  if (c < 32) return;
  c -= 32;
  memcpy_P(buffer, CH + 7*c, 7);
  m.writeSprite(32, 0, buffer);
  m.setColumn(32 + buffer[0], 0);
  
  for (int i=0; i<buffer[0]+1; i++) 
  {
    delay(shift_speed);
    m.shiftLeft(false, false);
  }
}

void printStringWithShift(char* s, int shift_speed){
  while (*s != 0){
    printCharWithShift(*s, shift_speed);
    s++;
  }
}

void printString(char* s)
{
  int col = 0;
  while (*s != 0)
  {
    if (*s < 32) continue;
    char c = *s - 32;
    memcpy_P(buffer, CH + 7*c, 7);
    m.writeSprite(col, 0, buffer);
    m.setColumn(col + buffer[0], 0);
    col += buffer[0] + 1;
    s++;
  }
}

Friday, September 28, 2018

how to make handheld phone stabiliser DIY Phone Steadycam

Homemade Handheld Phone Stabiliser or DIY Phone Steadycam made from wood popsicle sticks and I have add led strip that work on 9v battery so I can have more light.

Saturday, June 16, 2018

Arduino Wrist gadget with tiny oled screen

#include
#include
#include
#include

U8G2_SSD1306_128X32_UNIVISION_F_HW_I2C u8g2(U8G2_R0);

 void setup(void) {
   u8g2.begin();
}

  void loop(void) {
   u8g2.clearBuffer(); // clear the internal memory
   u8g2.setFont(u8g2_font_logisoso28_tr);  // choose a suitable font at https://github.com/olikraus/u8g2/wiki/fntlistall
   u8g2.drawStr(8,25,"grocery"); // write something to the internal memory
   u8g2.sendBuffer(); // transfer internal memory to the display
   delay(1000);

   u8g2.clearBuffer();         // clear the internal memory
   u8g2.setFont(u8g2_font_logisoso28_tr);  // choose a suitable font at https://github.com/olikraus/u8g2/wiki/fntlistall
   u8g2.drawStr(31,24,"list");  // write something to the internal memory
   u8g2.sendBuffer();         // transfer internal memory to the display
   delay(800);

   u8g2.clearBuffer();         // clear the internal memory
   u8g2.setFont(u8g2_font_logisoso28_tr);  // choose a suitable font at https://github.com/olikraus/u8g2/wiki/fntlistall
   u8g2.drawStr(10,29,"apples");  // write something to the internal memory
   u8g2.sendBuffer();         // transfer internal memory to the display
   delay(800);

   u8g2.clearBuffer();         // clear the internal memory
   u8g2.setFont(u8g2_font_logisoso28_tr);  // choose a suitable font at https://github.com/olikraus/u8g2/wiki/fntlistall
   u8g2.drawStr(4,29,"orange");  // write something to the internal memory
   u8g2.sendBuffer();         // transfer internal memory to the display
   delay(1000);

   u8g2.clearBuffer();         // clear the internal memory
   u8g2.setFont(u8g2_font_logisoso28_tr);  // choose a suitable font at https://github.com/olikraus/u8g2/wiki/fntlistall
   u8g2.drawStr(4,29,"Apricot");  // write something to the internal memory
   u8g2.sendBuffer();         // transfer internal memory to the display
   delay(1000);
}

Wednesday, April 4, 2018

Build a Vacation Pet Feeder!

Code:


/* Pet Feeder by William Finucane

 This code is for use with an automatic pet feeder made for the
Mad Science World at http://mad-science.wonderhowto.com/
The feeder uses a gluestick attached to a continuous rotation servo
as a linear actuator. This actuator opens and closes a compartment
of food every 12 hours to feed any domoestic animal

This example code is in the public domain.
*/
#include  

Servo myservo;  // create servo object to control a servo
                // a maximum of eight servo objects can be created


void setup()
{
  myservo.attach(10);  // attaches the servo on pin 9 to the servo object
}


void loop()
{
                                 
    myservo.write(80);             //open food gate
  delay(10500);                    //at this speed it takes 10.5
                                   //seconds to
                                   //open all the way
  myservo.write(120);              //close food gate
  delay(10000);                    // at this speed it takes 10 seconds
  myservo.write(96);               //hold gate still
  delay(43200000);                  //wait 12 hours
 
  /* the opening of the gate is longer than the closing to make
  sure the glue stick slide never comes out of the case. If the
  feeder is jostled, the extra half a second added upon closeing the
  gate will retighten the slide.
  */
}