22nd
JAN

WS2812b & DS1307 with Arduino

Posted by M. 4Gani under Electronic, Ring Clock Projecti:

Making a ring wall clock with 1-meter long WS2812B LED strip with 60 RGB LEDs.  (ماژول LED RGB WS2812)

 LED WS2812 حلقه یا RGB LED WS2812b پنج متری

 For clock I used a DS1307, which contains a real-time clock.

WS2812b & DS1307

Driver IC: I2C DS1307 Real Time Clock
SCL Analog 5 (clock line)
SDA: Analog 4 (data line)
Voltage: +3.3V to +5V
GND: GND of Arduino
I2C Address: 0x68

NeoPixel – WS2812B LED strip
Length of strip: 1-meter
Number of LEDS per meter: 60
DIN: Digital 3
VCC: +5V to +12V
GND: GND on Arduino

 

The WS2812B LED strip is an addressable RGB LED strip and each LED includes an IC built in. This gives LEDs the possibility to communicate through one-wire interface.

Each LED has a data in/out pin and requires 24 bits (for each color 8 bits) of data to work.
The data is shifted in an 8 bit for green, 8 bits for red and finally 8 bits for blue intensity. (Total 3 byte)
Once a LED receives 24 bits data at its data-in pin, it forwards the data through its data-out pin to the next LED’s data-in pin.

The LED strip should be powered by an external 5V-12V power source.
by setting LED to maximal brightness, the maximum current of  LED will be ca. 50mA  (0,05 A x 60 LED’s = 3,0 A).

To reduce noise on strip you need to  add a 220 or 470 Ohm resistor between the arduino digital output pin and the strip data input pin.

Arduino libraries:
Adafruit’s Neopixel and RTClib

Demo Code



// include the library code
#include <Adafruit_NeoPixel.h> 

#define PIN 3
#define NUM_LEDS 60

Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);
RTC_DS1307 RTC;       // establish clock object

DateTime now;         // holds current clock time
byte hrs, mins, secs; 

int BLINK_PIN = 13;

void setup() {
  delay(1000);       // 1 second delay for recovery
  Serial.begin(9600);
  pinMode(BLINK_PIN, INPUT);
  if (!RTC.begin()) {
    Serial.println("Couldn't find RTC");
    while(1);
  }
  if (!RTC.isrunning()) {
    Serial.println("RTC is NOT running!");
    RTC.adjust(DateTime(F(__DATE__), F(__TIME__)));
  }
  Wire.begin();
  strip.begin();
  strip.show();       // Initialize all pixels to 'off'
  delay(500);
}

void loop() {
  DateTime now = RTC.now();
  secs = now.second();  // get seconds
  mins = now.minute();  // get minutes
  hrs = now.hour();     // get hours
  Serial.print("rtc:\t");
  Serial.print(now.year()); Serial.print("-");
  Serial.print(now.month()); Serial.print("-");
  Serial.print(now.day()); Serial.print(" ");
  Serial.print(hrs); Serial.print(":");
  Serial.print(mins); Serial.print(":");
  Serial.println(secs);  
  strip.setPixelColor(secs, 0x000055);
  strip.setPixelColor(mins, 0x550000);
  strip.setPixelColor(hrs, 0x005500);
  anyNr1(0, 0, 127); Serial.print("function: anyNr1\n");
  delay(200);
}

// fill
void anyNr1(byte red, byte green, byte blue) {
  int l;
  for(l=NUM_LEDS+1; l>secs; l--) {  
    LToRight(l, red, green, blue);
    for(int n=0; n<NUM_LEDS; n++) {
      if (n <= secs) {
        if (n != mins && n != hrs) strip.setPixelColor(n, 0x000055);
      } else {
        if (n != mins && n != hrs) strip.setPixelColor(n, strip.Color(0, 0, 0));
      }
    }
    strip.show();
  } 
}

void setPixel(int Pixel, byte red, byte green, byte blue) {
  strip.setPixelColor(Pixel, strip.Color(red, green, blue));
}

void LToRight(int i, byte red, byte green, byte blue) {
  if (i != secs && i != mins && i != hrs) 
    setPixel(i, red, green, blue);  
  if (i+1 != secs && i+1 != mins && i+1 != hrs) 
    setPixel(i+1, red/5, green/5, blue/5); 
  if (i+2 != secs && i+2 != mins && i+2 != hrs) 
    setPixel(i+2, red/10, green/10, blue/10);
  if (i+3 != secs && i+3 != mins && i+3 != hrs) 
    setPixel(i+3, red/20, green/20, blue/20);
  if (i+4 != secs && i+4 != mins && i+4 != hrs) 
    setPixel(i+4, red/30, green/30, blue/30);
  if (i+5 != secs && i+5 != mins && i+5 != hrs) 
    setPixel(i+5, red/90, green/90, blue/90);
  strip.setPixelColor(secs, 0x000055);
  strip.setPixelColor(mins, 0x550000);
  strip.setPixelColor(hrs, 0x005500);
  strip.show();
  delay(20);
}

 

Continue…

 

22nd

LDR Sensor with Arduino

Posted by M. 4Gani under Electronic, Ring Clock Projecti:

The LDR Sensor also know as the Photo-resistor is basically a simple sensor that its resistance value changes with light. (resistance will lower with more light.)
The LDR isn’t very precise, so you can not get a LUX reading but it is good enough to tell the difference between light and shadow.
It can be used to make:

  • Automatic light dimmer
  • Light sensitive switch

    LDR Sensor with Arduino

    LDR Sensor with Arduino

Parts List

  • Arduino
  • LDR (also known as a photocell)
  • LED with 220 to 330 ohm resistor
  • 1K to 10K resistor (used with the LDR to setup a voltage divider)

Connections

The LDR is a special type of resistor which allows higher voltages to pass through it.
It means with a high intensity of light a low voltage passes.

The circuit based on a photo resistor that uses a resistor divider (4.7K to 10K) to allow the high impedance analog input to measure the voltage.
To get a voltage proportional to the photoresistor value, a resistor divider is necessary.

For demonstration we use an additional LED to digital pin 13 in series with the 220 ohm resistor.

Following formula is used  to calculate the voltage at A0 pin (Vout):

Vout=Vin*(R2/(R1+R2))

The voltage input (Vin) referenced to 5V expressed as a 10 bit value.
In other words 5V gets split up into 1024 levels, that is 5/1024 = 0.0048828125 volts per unit returned back.

ADC (analog-to-digital converter) of microcontroller converts and maps the analog value of the LDR from 0-5 volt to a value in 0-1023 range (digital 0-255).

 
/*
 Reading an analog sensor on analog pin 0 and
 turning on and off a light emitting diode(LED Digital 13).
 http://www.arduino.cc/en/Tutorial/AnalogInput
*/
int sensorPin = A0;    // select the input pin for the potentiometer and 10K pulldown
int ledPin = 13;       // select the pin for the LED

void setup() {
  Serial.begin(9600);     // serial connection
  // declare the ledPin as an OUTPUT:
  pinMode(ledPin, OUTPUT);
}

void loop() {
  // read the value from the sensor and converts to 0 to 1023 range by using ADC
  sensorValue = analogRead(sensorPin);
  digitalWrite(ledPin, HIGH);   // turn the ledPin on
  delay(1000);                  // waits for a second
  digitalWrite(ledPin, LOW);    // turn the ledPin off
  delay(1000);
  // map it to the range of the analog out
  int outputValue = map(sensorValue, 0, 1023, 0, 255);
  analogWrite(ledPin, outputValue); // change the analog out value
  // print the results to the Serial Monitor
  Serial.print("sensor = "); Serial.print(sensorValue);
  Serial.print("\t output = "); Serial.println(outputValue);
 }
 

22nd

DS1307 & TM1637 with Arduino

Posted by M. 4Gani under Electronic, Ring Clock Projecti:

Making a Digital clock with Arduino boards.  (ماژول ساعت DS1307)

DS1307 & TM1637 with Arduino

DS1307 & TM1637 with Arduino

Components
• Arduino board
• DS1307 RTC Module  I2C (SDA and SCL)
• TM1637 7-segment I2C (CLK and DIO)

The DS1307 uses I2C Protocol to communicate with arduino.

There are a lot of examples on the Web to show how to use Wire library.

The Wire library  makes DS1307 RTC easier  to use for getting/setting the time.

Driver IC: DS1307 real clock
SCL:  Analog 5  (clock line)
SDA:  Analog 4  (data line)
Voltage: +3.3V to +5V
GND:  GND of Arduino

Typically you want to use 2.2K or 2.4K resistors between each of the SDA and SCL pins and  +3.3v of arduino.

For my module, I do NOT need pull-up resistors.
The TM1637 also uses I2C Protocol to communicate with arduino.

Driver IC: TM1637 display 7-Segment
Voltage: +3.3V to +5V
Interface: I2C
CLK: Digital 9
DIO: Digital 8
GND:  GND of Arduino
8 adjustable luminance levels

The CLK and DIO on display can connect to any of arduino digital pins. I use for DIO pin the D8 and for CLK pin the D9 Pins.

Arduino libraries:
// DS1307 & TM1637 7-segment with Arduino
#include 
#include "TM1637.h"
// pins definitions for TM1637 and can be changed to other ports       
#define CLK 2
#define DIO 3
TM1637 tm1637(CLK,DIO);
// Holds current clock time
RTC_DS1307 RTC; 
DateTime theTime; 
int8_t TimeDisp[] = {0xff, 0xff, 0xff, 0xff};

void setup() {
  Serial.begin(9600);
  if (!RTC.begin()) {
    Serial.println("Couldn't find RTC");
    while(1);
  }
  if (!RTC.isrunning()) {
    Serial.println("RTC is NOT running!");
    RTC.adjust(DateTime(F(__DATE__), F(__TIME__)));
  }
  tm1637.init();
  tm1637.set(2);         // TYPICAL = 2, DARKEST = 0, BRIGHTEST = 7;
  tm1637.display(0,10);  // show A B C D for testing
  tm1637.display(1,11);   
  tm1637.display(2,12); 
  tm1637.display(3,13);
  delay(3000);
}

int hour, minute, second;
unsigned char ClockPoint = 1;
 
void loop() {
  DateTime theTime = RTC.now();
  second = theTime.second();  // get seconds
  minute = theTime.minute();  // get minutes

  TimeDisp[0] = minute / 10;
  TimeDisp[1] = minute % 10;
  TimeDisp[2] = second / 10;
  TimeDisp[3] = second % 10;
  
  tm1637.display(0,TimeDisp[0]);
  tm1637.display(1,TimeDisp[1]); 
  tm1637.display(2,TimeDisp[2]);
  tm1637.display(3,TimeDisp[3]);
  Serial.print("Set to ");
  Serial.print(hour);
  Serial.print(":");
  Serial.print(minute);
  Serial.print(":");
  Serial.print(second);
  Serial.println();
  ClockPoint = (~ClockPoint) & 0x01;
  if(ClockPoint)tm1637.point(POINT_ON);
  else tm1637.point(POINT_OFF); 
  delay(1000);  
}

Continue….

7th
AUG

Make a Bluetooth speaker

Posted by M. 4Gani under Electronici:

I’m using BK8000L Bluetooth module (SBC audio decoding performance) and as amplifier the PAM8403  board. (but you can use any other amplifier for example from you old PC speaker)

Problem with feedback and noise

If  we want to power the both devices from the same power supply, It will get a lot of noise. (ground loop noise)
To eliminate sound noise we should using separate power supply to drive the Bluetooth and amplifier.

Main component are:
– Bluetooth Stereo Audio Module Transmission BK8000L
PAM8610 2x15W Amplifier Board Digital
– Power supply ca 7 to 9V for PAM8610 and 3.3v for Bluetooth
– Two speakers

For 3.3V power for BK8000L I used a simple USB/AC Adapter charger and with a AMS1117 Voltage regulator convert the 5 volt output to 3.3 volt.
Keep in mind to added 100 uF and .1 uF capacitor between VCC and GND.

Recommend is to use a 100uF/25V electrolytic capacitors between VCC and GND.

22nd
JUL

Notebook power supply modification

Posted by M. 4Gani under Electronici:

 

Modification of IBM notebook power supply

How can I modify the output of power supply from 16.8 to 12 volt?

Most of the switched mode supplies are normally provide with a reference voltage to regulate the output, which is the heart of the device.

Identify the voltage divider:

First I opened the case and looked for the feedback circuit and voltage divider.

Then, I tried to locate the two resistors that are responsible for setting  the output voltage.

The stabilization of the output voltage can be archived in the same way as TL431 (TL431  will be used in chip switching mode supplies and you can find many documents about its functionality in internet).

Vo=Vref*(1+R1/R2)

I already knew, that the location these two resistors can be found near the opt-coupler.

Only R1 is interesting for me. I can simply add an additional resistor in parallel to it and reduce the total value.

The resistor Rx51 on board as you see in the picture can be a good candidate. I measure the value and it was 976 ohm .
Measure the voltage at the opt-coupler was about 1.9V

 

On the left side of the board I found a tiny circuit board, which is shown in the picture. I assume its functionality is the same as TL431.

Additionally, on the tiny broad I found the resistor R62 with 1.9 K in series to RX51.

I soldered parallel to R62 (1.9K) a new 6.8K resistor.
The result was 1.4K and gave me an output of 11.8 Volt and max 3.4 Amper

 

 

See more website here...

  • Odlinks
  • Farsi-News
  • Advertise Here