Home Blog Page 19

How To Change A Euro Cylinder Profile Lock On A UPVC And Composite Door

The term “cylinder lock” could mean a large number of different locks, but in today’s guide, we will focus on one type of cylinder – the Euro cylinder. The Euro cylinder was first patented in 1805 and was an attempt by European locksmiths to standardise locks, which, in Europe and other parts of the world has been largely successful. Euro cylinders are now a common sight on the external doors of many homes. In the United States, Euro cylinders are used primarily on sliding glass doors and internal doors which divide two rooms.

Euro cylinders are easy to change or upgrade, and here at The DIY Life, we love to save you both time and money. There is no need to call a locksmith or handyman as these are one of the easiest locks to change, due to the cylinder being self-contained, their standardisation and wide availability. In fact, the most important part is the preparation.

To Change A Euro Cylinder You Will Need

  • 1 Phillips Screwdriver OR 1 Torx Screwdriver (depending on the screw type)
  • 1 Euro Cylinder Lock (Do NOT BUY before you have extracted the lock as you need the correct size)
  • Your existing Euro cylinder key

How To Change The Lock

1. Firstly open the door so you can comfortably stand by the side of it.

2. Next, locate the Euro cylinder on the door, then locate the central screw on the side of the door. This is the screw that keeps the Euro cylinder in place.

3. Identify which screwdriver is appropriate to use, then remove the screw. Normally this will be a Phillips, but may also be a Torx screw and very rarely may be a flat head.

How To Change A Euro Cylinder Lock

4. Once the screw is removed, insert your key into the lock and turn it about an 8th of the way or to approximately to 2 O’clock, this is to align the cam (middle of the lock). Once aligned, pull the key and lock towards you until you feel a release. You sometimes need to loosen the screws to the door handle to make this easier, but will not usually be necessary. This can be a bit tricky, but just remember, all it is is an alignment issue. Loosen the door handle, turn the key to align the cam and wiggle the lock out.

5. Now the Euro cylinder should be in your hand, giving you the opportunity to measure it. You can measure the size of a Euro cylinder by finding the central screw hole on the lock. Grab a tape measure and measure from the central screw hole to the end of the cylinder, measure both ways. Your measurement should be something like 35mm by 35 mm (As seen below) or 45mm by 50mm etc. However, this size is only correct if your lock is the correct size for the door in the first place. The cylinder should be flush to the door with none of the cylinder being exposed. If the cylinder is exposed then measure from the central screw hole to where the lock would fit flush to the door, this should be identifiable with a weathered line on the lock, where some of the lock has been exposed to the elements. This exposure of the lock is a serious security risk and makes bypassing the lock much easier with a technique called lock snapping (more on that later).

6. There are approximately 25 different sizes, so ensure you have measured the size correctly. Alternatively, if possible, you could take the lock with you to ensure you purchase the exact size needed.

Euro Cam

7. Now travel to your local hardware store and purchase the correct size replacement cylinder.

8. Once you have the new cylinder, insert your new key into it and turn it an 8th of the way, so the cam (the middle) is aligned, allowing you to insert the lock into your door. The exact same way you took it out but in reverse. This bit can be as tricky as getting the lock out, remember it’s just an alignment issue so just fiddle around and it will eventually come right.

9. Once the lock is fitted nicely and is flush with the door, use the old screw you took out of your previous lock and insert it into the central screw hole and tighten it. We recommend using the old screw as it will be the correct length, sometimes a new screw will be too long and will have to be cut to size. Alternatively, if the new screw is the same size and doesn’t require cutting,  then use the new screw. Don’t forget to keep your cylinder measurement for future maintenance.

10. To test that it has all been done correctly, lift the handle and turn the key to lock the lock with the door open. Lock the cylinder a few times to test it. Once you have seen this working it properly, it should be safe to shut the door and lock it.

Euro cylinders are great locks and are renowned for being difficult to pick, however, they do possess some natural weaknesses. one big vulnerability to the security of your door is called snapping. Lock snapping is exactly what the name suggests, it literally means snapping the lock in two. The scariest thing is that this technique can be successfully done in as little as 15 seconds, and the tools required to snap a lock can be found almost anywhere.  This can be overcome by purchasing anti-snap locks with a sacrificial section. Instead of the lock snapping in half, the sacrificial section will break off leaving the rest of the lock within the door, safe from another snapping attempt.

Another vulnerability of the euro cylinder is drilling. Like most locks, the Euro cylinder can be drilled within minutes. While this cannot be overcome, you can purchase euro cylinders with anti-drill pins within them. This does not stop drilling, but it does make drilling a harder and longer process.

Generally higher quality Euro cylinders are made out of stronger and sturdier materials, they also contain more anti-drill pins, in addition to other security feature,s such as anti-bump pins, sacrificial sections and magnetic operating locks, making picking extremely difficult. If your Euro cylinder is for an external door you should consider purchasing a high-security lock, as this will be much more resistant to any bypassing techniques used by criminals, making it harder for them to enter your property. More on this and other helpful security tips and advice can be found on ITCC Locksmith’s blog section.

Have you tried changing your own Euro cylinder lock? Let us know in the comments section below.

Share This Guide

Change A Euro Cylinder Lock Yourself - Step by Step

How to Make Your Own Inexpensive Chandelier

Few home decor accessories look as regal as a chandelier. The problem is that chandeliers usually cost a pretty penny. Whether you’re on a budget or just looking for a new home improvement DIY project, making your own chandelier is fun, easy, and surprisingly affordable.

As you read this guide on chandelier making, remember that these are just suggestions and not requirements. You can use the basic design as-is, or feel free to get creative and modify it to fit your unique style preferences. The possibilities are endless!

1. Gather Materials

If you do a lot of DIY projects, there’s a good chance you’ll already have a lot of these materials lying around the house. If not, you should be able to obtain them fairly easily—check hardware, junk stores, and other retailers that sell lamp and light fixture parts.

If you’re struggling to find a particular item, try to think outside the box. You should be able to come up with a solution, even if it’s not exactly what you initially had in mind.

Here’s a general idea of what types of materials you’re going to need:

  • A top base to hold the suspended items (repurposed wood, a bicycle wheel, or a wire cooking rack are all great choices)
  • At least 10 feet of lightweight wire lamp chain or other lamp cord
  • 14-gauge (1.5mm^2) wire
  • At least six small Mason jars (or exposed light bulbs of your choice)
  • A one-inch circular metal ring
  • A swag hook or other hardware for hanging the chandelier
  • Pliers
  • Wire cutters

Hanging Wooden DIY Chandelier

2. Attach the Chains or Cord to Your Top Base

The metal ring is going to be your point of contact to the ceiling. When you’re finished with your chandelier, you can use the ring to hang it from a hook. Start by using your wire cutters to cut the lamp chain or cord into four equal-sized pieces. The length depends on the size of your base, but around 16  (400mm) to 24 (600mm) inches should do the trick.

If you’re using chains, take your pliers and open the top link of each chain. Attach the chain to the metal ring, and then use your pliers to squeeze the chainlink back into place. Repeat this step for all four chains. You should end up with four equal lengths of chain hanging from the ring.

If you’re using a flexible cloth-covered cord, consider wrapping the material around your base in a way that matches the aesthetic you’re going for.

3. Attach the Cord to the Base

Now you’re going to repeat the same process to attach the bottom of the chains to your wheel, wire cooking rack, or other base. If your base is thicker than your chain links, you might need to get creative. You could use wire to wrap the bottom chain link to the perimeters of your base.

When you’re done attaching all four chains, you should be able to hold the top ring, and the base should hang evenly. If it’s crooked, you might need to trim the chains to make sure they’re all the exact same size.

4. Create Wire Handles on the Jars

Hanging Mason Jars To Make A DIY Chandelier
Credit: Color Cord Company

Next, you’re going to create wire ‘handles’ so you can hang each jar from the base. Cut your wires so they’re 24 inches (600mm) long. Wrap the wire securely around the lip of your Mason jars, leaving at least 8 inches (200mm) of slack like a tail. You’ll attach the other end of the wire ‘tail’ to the jar eventually, but not yet.

Pro tip: You could also leave the lids on, drill a hole in the tops of the lids, and attach the jars directly to the base using rope or twine for a rustic look. Simply thread it through and tie a knot in the bottom to prevent it from slipping out.

5. Thread the Wires Through the Bottom Chain Links

Cut six (or more) pieces of lamp chain to hang the jars. You can cut the chains into random lengths, or measure them if you want a symmetrical design. Now it’s time to thread the ‘tail’ of the wire handles on your jar through the bottom chain links. Secure the end of the wire to the other side of the jar, creating a U-shaped handle. Repeat these for all of the jars.

6. Attach the Jars to the Base

Now you have six or more jars with chains attached. You might need a friend for this next step. Hang your base from the ceiling, and attach the top of the chains to the base, one-by-one. Be sure to position them in areas that keep the weight of the structure balanced. It’s important to attach the jars while the chandelier is hanging, otherwise, you risk it being lopsided.

7. Add More Flair

You can leave the chandelier as-is if you want a classic, bucolic look. Minimalism is a popular architecture trend, so feel free to keep it simple. For a stronger visual effect, you could use your leftover light cord or chain to hang beads, crystals, shells, ornaments, antique bottles, or anything else that catches your eye. Feel free to get creative with it.

If you really want to make your new chandelier pop, consider painting it. A quick coat or two of spray paint will help to transform an old wheel or baking rack into a more realistic base. A coat of white paint is a safe and elegant option, but don’t be afraid to match it to your home’s unique colour scheme.

8. Light It Up

DIY Chandelier

Congratulations, your chandelier is finished! The last step is to light it up and enjoy. If you’re using candles, simply light them and drop them into the jars. Just make sure you follow candle safety guidelines to prevent fires.

If you prefer electricity, you could also consider using lamp parts and an extension cord or even wireless LEDs to add bulbs to the jars. Or, you could consider hanging your chandelier underneath an existing ceiling light fixture so the light can radiate off the glass naturally. Be sure to follow electrical safety guidelines if you’re doing any wiring on your own, or hire a contractor to help you with wiring your new light fixture.

Note: Make sure that you check your local regulations before doing any electrical work, some area do not permit unlicensed electrical work to be carried out.

Keep Adding To Your Chandelier

The great thing about this project is that you can keep modifying it over time. Just keep some spare chain and wire on hand, and you’ll be able to attach new pieces whenever the mood strikes. If your first chandelier doesn’t turn out as well as you were hoping, learn from your mistakes and try again! The materials are cheap, so why not experiment with your design?

Have you tried making your own chandelier? Let us know what you made in the comments section below.

An Arduino Playing The Chrome Dino Game On Another Arduino

You may have seen people using an Arduino to automate playing the Chrome Dino Game in their browser, I thought we could take it a bit further and see if we could get one Arduino to play the Chrome Dino Game on another Arduino.

I’ve previously set up an Arduino to run a simple version of the game, which produces a continuous stream of randomly spaced cactuses at an increasing speed, and closer together. The game is really easy to get running and only requires an Arduino Uno and an LCD keypad shield. A single button on the keypad shield is then used to make the dinosaur jump over each cactus until the player messes up and hits one. The score is kept based on how long you’re able to avoid running into a cactus.

Once I had the game running on one Arduino, I set up a second one, which uses an LDR to sense each cactus and then moves a servo to press the button on the other Arduino to make the dinosaur jump over each cactus.

Here’s a video of the build and the one Arduino playing the Chrome Dino Game on the other:

We’ll first have a look at running the dino game on an Arduino and then set up a second to play the game on the first. The code would be the same to set the second Arduino up to play on your computer’s browser as well, you’d just need to stick the LDR to the display.

What You Need For This Project

For The Dino Game

For The Dino Game Player

How To Load The Chrome Dino Game

Let me start out by saying – I didn’t code the dino game. It’s a version I found on Hackster.io which was the least complicated layout and ran the smoothest. One downside is that it’s written in AVR C code, so it looks a little different to the generic Arduino language but you should still be able to figure a lot of it out, I’ve also expanded on the description of the game and explained how you can change a few things around in another post – How to Play the Chrome Dino Game onto an Arduino.

Here’s a general overview of the game:

  • You push a button on the keypad shield to make the dinosaur jump over each cactus.
  • The game speed up the longer you play it.
  • Cactuses are initially separated by a minimum of 5 spaces and this goes down to 4 as the game progresses.
  • The current score is displayed throughout the game and is joined by the high score at the end of the game.
  • Cheating by holding down the button or continuously pressing the button is prevented.

I have made a couple of changes to the original version of the code for the timing, cactus spacing and the text layouts to better accommodate the sensor.

Here is the code:

//From Hackster.io
//By BRZI

#include <avr/io.h>
#define  F_CPU 16000000UL //Our CPU speed (16MHz)
#include <util/delay.h> //Libraries for delay and interrupt utilities
#include <avr/interrupt.h>
#define command 0 //explained in dispSend() function
#define write 1

uint8_t upperBuff[16] , downerBuff[16], overMsgUpper[] = "Score:  ", overMsgDowner[] = "Best:   ", scoremsg[] = "Score:" , din[] = {0x0E, 0x17, 0x1E, 0x1F, 0x18, 0x1F, 0x1A, 0x12}, cact[] = {0x04, 0x05, 0x15, 0x15, 0x16, 0x0C, 0x04, 0x04};
        //Buffers for line one and two. Message to display after lost game.                     //Score text during game. //Dinosaur and cactus bitmaps
uint8_t canup = 1, longhold = 0, distance = 6, speed = 200, isup = 0, dontprint = 0; //All of these are explained further
uint16_t aVal = 0, score = 1, bestscore = 0;
int i;

void dispInit();
void dispWrite(uint8_t bits);
void dispSend(uint8_t bits, uint8_t act);
void dispSetLine(uint8_t line);
void dispClear();
void dispHome();
void dispPrintChar(uint8_t chr[], uint8_t size);
uint16_t aRead();

int main(void)
{
  for(i = 0; i < 17; i++) downerBuff[i] = ' '; //Initialize upper and downward buffer
  for(i = 0; i < 17; i++) upperBuff[i] = ' ';
  
  dispInit(); //Initialize the display
  
  TCCR1B |= (1 << WGM12) | (1 << CS11); //Set Timer1 to compare to OCR1A and prescaler of 8
  OCR1AH = (500 >> 8); //This equals to 2000Hz or 500us timing, look for TIMER1_COMPA_vect down below
  OCR1AL = 500;
  TIMSK1 |= (1 << OCIE1A); //Enable Timer1 CompA ISR
  sei(); //Enable global interrupt

  
  ADMUX = (1 << REFS0); //Set AREF to VCC
  ADCSRA = (1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0) | (1 << ADEN); //set ADC prescaler to 128 and enable ADC (defaulted to free running mode)
  
  while (1) {   
    
    ADMUX |= (1 << MUX2) | (1 << MUX0); //Set pin from ADMUX to ADC5 (floating)
    srand(aRead()); //Use it as a random seed
    ADMUX &= ~(1 << MUX2) & ~(1 << MUX0); //Revert back to ADC0 to read the button value

    if(aRead() > 900) longhold = 0; //Reads if Up button has been released to prevent cheating. The value is so low because if you hold your fingers beneath one of the buttons the voltage would drop, this prevents the dinosaur from locking up

    for(i = 0; i < 16; i++) downerBuff[i] = downerBuff[i + 1]; //Shifts everything in downward buffer by one place to the left
     if((rand() % 100) > (rand() % 100) && !dontprint){ //This portion decides if it should put a cactus or a blank spot, dontprint is used to prevent cactus grouping
      downerBuff[15] = 0x01; //0x01 represents the cactus (we added cactus and dinosaur to CGRAM when we initialized the display)
      dontprint = 1; //This part acts both as a boolean and a counter to ensure cactus separation
     }
     else downerBuff[15] = ' ';
     char lastchar = downerBuff[3]; //We remember the whats initially added to the downward buffer before replacing it with the dinosaur
     if(!isup){ //If din should be placed down
      downerBuff[3] = 0x00; //Place it down
      dispSetLine(2);
      dispPrintChar(downerBuff, sizeof(downerBuff)); //Draw it
      downerBuff[3] = lastchar; //Place back previous thing to the buffer
      canup = 1;  //This flag is used to disable dinosaur from getting up before it was drawn down, in this case he can go up
    } else { //If din should be placed up
      upperBuff[3] = 0x00; //Place it up in upper buff
      dispSetLine(1);
      dispPrintChar(upperBuff, sizeof(upperBuff));
      dispSetLine(2);
      dispPrintChar(downerBuff, sizeof(downerBuff)); //Draw it
      canup = 0; //In this case he wont go up until rendered on line 2
    }

    if(dontprint) dontprint++;
    if(dontprint > distance) dontprint = 0; //This is the part that ensures cactus separation, it will keep the cactus 3-5 spaces apart minimally (depends on the game progress)
    
    if(isup) isup++; //This part makes sure din is on upper side for 3 loops after he was initially drawn there
    if(isup > 4){
     upperBuff[3] = ' ';
     dispSetLine(1);
     dispPrintChar(upperBuff, sizeof(upperBuff));
     isup = 0;
    }
    for(i = 0; i < sizeof(scoremsg); i++) upperBuff[i + 5] = scoremsg[i]; //This part prints the current score during the game
    uint8_t cnt = 11;
    for(i = 10000; i > 0; i /= 10){
      upperBuff[cnt] = ((score / i) % 10) + '0';
      cnt++;
      dispSetLine(1);
      dispPrintChar(upperBuff, sizeof(upperBuff));
    }

    score++; //Increment the score once on loop
    if(score > bestscore) bestscore = score; //Remember best score
    
    if(lastchar == 0x01 && !isup){ //Check if the dinosaur is downward and hit a cactus
      dispClear(); //Clear the display and buffers
      for(i = 0; i < 17; i++) downerBuff[i] = ' ';
      for(i = 0; i < 17; i++) upperBuff[i] = ' ';
      uint8_t cnt;
      
      dispSetLine(1);
      for(i = 0; i < sizeof(overMsgUpper); i++) upperBuff[i] = overMsgUpper[i]; //Display worst and best score
      cnt = sizeof(overMsgUpper) - 1;
      for(i = 10000; i > 0; i /= 10){
        upperBuff[cnt] = ((score / i) % 10) + '0';
        cnt++;
      }
      dispPrintChar(upperBuff, sizeof(upperBuff));
      
      dispSetLine(2);
      for(i = 0; i < sizeof(overMsgDowner); i++) downerBuff[i] = overMsgDowner[i];
      cnt = sizeof(overMsgDowner) - 1;
      for(i = 10000; i > 0; i /= 10){
        downerBuff[cnt] = ((bestscore / i) % 10) + '0';
        cnt++;
      }
      dispPrintChar(downerBuff, sizeof(downerBuff));
      
      while(1){ //Wait for select button to be pressed
        aVal = aRead();
        if(aVal > 635 && aVal < 645){ //After that clear all the variables
          for(i = 0; i < 17; i++) downerBuff[i] = ' ';
          dispSetLine(1);
          dispPrintChar(downerBuff, sizeof(downerBuff));
          for(i = 0; i < 17; i++) upperBuff[i] = ' ';
          dispSetLine(2);
          dispPrintChar(upperBuff, sizeof(upperBuff));
          dontprint = 0;
          isup = 0;
          score = 1;
          speed = 200;
          longhold = 0;
          distance = 6;
          canup = 1;
          break;
             }
      }
      
    }
    if(score % 5 == 0) speed -=1; //If score is divisible by 5 make game faster by -2ms
    if(speed < 120) speed = 120; //Minimal time in ms (+ ~2ms) that the loop will be halted for (limited by display refreshing, in my testing 11.8Hz was readable enough to be playable)
    if(score % 175 == 0) distance--; //Every time you score a number divisible by 175 minimal cactus distance gets smaller
    if(distance < 4) distance = 4;
    for(i = 0; i < speed; i++) _delay_ms(1); //This is the only way as the compiler expects a const number here
  }
}

void dispInit(){
  _delay_ms(50); //Just in case
  DDRD = 0b11110000; //Set these pins to output. PD4 - PD7 correspond to D4 - D7 on display, we need to configure it to run in 4 bit mode
  DDRB = 0b00000011; //PB0 is tied to RS and PB1 to EN
  dispWrite(0x30);//*This part here is explained in Hitachi HD44780 datasheet on how to initialize the display in 4bit mode
  _delay_us(4500);//*Essentially you send the reset signal 3 times, and then set it to 4 bit mode
  dispWrite(0x30);//*
  _delay_us(4500);//*
  dispWrite(0x30);//*
  _delay_us(4500);//*
  dispWrite(0x28);//*
  dispSend(0x28, command); //Send 4bit mode function set
  dispSend(0x08, command); //Turn the display off
  dispSend(0x01, command); //Clear its RAM (if MCU resets that doesn't mean the display was reset, so we clear everything)
    _delay_ms(50);
  dispSend(0x0C, command); //Turn the display on
  _delay_ms(5);
  dispSend(0x40, command); //Tell the display we want to enter a custom character to its CGRAM (on address 0x00)
  for(i=0; i<8; i++) dispSend(din[i], write);
  dispSend(0x80, command); //Transaction end
  dispSend(0x48, command); //Same thing, but for 0x01
  for(i=0; i<8; i++) dispSend(cact[i], write);
  dispSend(0x80, command);
}

void dispPrintChar(uint8_t chr[], uint8_t size){
  for(uint8_t i = 0; i < size; i++) dispSend(chr[i], write); //Self explanatory 
}

void dispSetLine(uint8_t line){
  if(line == 2) dispSend(0xC0, command); //Sets the line where 0xC0 is line 2 and 0x80 is line 1
  else dispSend(0x80, command);
}

void dispClear(){
  dispSend(0x01, command); //Self explanatory 
  _delay_ms(2); //This command takes longer for the IC to process, this delay is necessary
}

void dispHome(){ //This function isn't used in this application but its there for expandability, it places the cursor on the line 1 column 1
  dispSend(0x02, command); //Self explanatory 
  _delay_ms(2);
}

void dispSend(uint8_t bits, uint8_t act){
  if(act) PORTB |= (1 << DDB0); //Set PB0 if we are writing a character, else pull it low
  else PORTB &= ~(1<<DDB0);
  dispWrite(bits); //Send the bit then shift them 4 bit to the left to work in displays 4bit mode
  dispWrite(bits << 4);
  _delay_us(80);
}

void dispWrite(uint8_t bits){
  PORTD = bits; //This is a dirty way to write it but it's perfect for this application as it's not bulky and PORTD isn't used for anything else anyway
  PORTB |= (1<<DDB1); //Pulse the PB1 to signal the IC to read the data
  _delay_us(1);
  PORTB &= ~(1<<DDB1);
  _delay_us(1);
}

uint16_t aRead(){
  ADCSRA |= (1 << ADSC); //This signal the avr to read the ADC value
  while  (ADCSRA & (1 << ADSC)); //Wait until it's finished
  return ADCL | (ADCH << 8); //Send it back stitched together
}

ISR (TIMER1_COMPA_vect){ //Timer ISR we set up earlier
  if(!longhold){ //Return if the Up button was still held
    aVal = aRead(); //Read from ADC0
    if(aVal > 450 && aVal < 600 && canup){ //Check if Up is pressed and that din was rendered down
     isup = 1;
     longhold++;
     }
    }
}

Download The Code – DinoGame

The game is quite easy to play on the LCD keypad shield, although the buttons are not the best for quick presses, and the LCD is quite slow, so it starts suffering from ghosting and brightness issues once the cactuses start moving quickly.

Playing The Chrome Dino Game On An Arduino

Setting Up An Arduino To Play The Chrome Dino Game

Now that we’ve got the game running on our first Arduino, let’s try and get the second one playing the Chrome Dino Game on the first.

The components and wiring are quite simple, they involve basic starter circuits for the LDR, LED and servo. I initially included the LED to light up when each cactus was detected but the light started interfering with the LDR, so I turned it off. You can leave this LED out if you want to or cover it up slightly with tape so that it doesn’t interfere with the surrounding components.

Schematic - Arduino Chrome Dino Game Player

I connected the components together using a few strips of ribbon cable and some header pins to make it easier to plug into the Arduino and the servo.

Soldering Components

Ribbon Cable Connector

You’ll need to glue the servo onto a box or stand just above the left button on the keypad shield so that the servo arm pushes the button down when it rotates. You’ll then need to glue the LDR onto the edge of the LCD screen as close to the screen as possible. It needs to be positioned over the 7th character from the left of the display in the second row.

Arduino Playing The Chrome Dino Game On Another Arduino - Side

Make sure that the LED is covered, turned off or pointed away from the display so that the light from the LED doesn’t interfere with the LDR sensing the cactuses. The first few runs I had were interrupted by the LED causing false cactus readings by the LDR, so it turned it off.

Servo Pressing Jump Button

Now let’s have a look at the player code.

//Michael Klements
//The DIY Life
//8 May 2020

#include <Servo.h>

Servo player;         //Create a servo object to control the button servo
int cactus = 0;       //Variable to read in LDR value
int cactusVal = 770;  //LDR Sensor value when detecting a cactus

void setup()
{
  //Serial.begin(9600);
  player.attach(6);     //Set the player servo pin to pin 6
  player.write(75);     //Set the servo to an initial position just above the button
}

void loop()
{
  cactus = analogRead(A0);          //Read the output from the LDR to detect a cactus
  //Serial.println(cactus);         //Used for calibration
  if (cactus > cactusVal)           //If a cactus is detected
  {
    player.write(60);               //Move the servo to push the jump button
    delay(300);                     //Wait 300 milliseconds
    player.write(75);               //Move the servo back to the initial position
    delay(100);
  }
}

Download The Code – DinoGamePlayer

We start by including the servo library to control the servo.

We then create a servo object called player to control the servo and then create two variables, one to store the value read from the LDR and a second to store the light level set point when a cactus passes in front of the LDR.

In the setup function we set the servo pin number and set the servo position slightly above the jump button. You’ll also need the Serial monitor for calibration, this is detailed further on.

In the loop function, we read in the LDR sensor level, then compare it to the cactus set point. If the measured level is greater than the cactus set point, indicating a cactus is passing the sensor, then we move the servo downwards to push the button, wait 300 milliseconds for the servo to move and for the game to register the input and then move the servo back up for the next push. The second delay is to avoid repeated servo movements, this could be reduced to 50ms.

I’ve also included a serial monitor printout of the sensor value which is used initially to set the cactus value set point. You’ll need to run the game and display the sensor values and then see what value is measured when a cactus runs past the sensor and update this value in the code accordingly. This step is detailed in the video at the beginning of the project.

One Arduino Playing The Chrome Dino Game On Another

Upload the code and calibrate the sensor and you’re ready to try it out. Startup the player Arduino first and then start the game on the other. Press the reset button on the LCD shield to start a new game.

Arduino Playing The Chrome Dino Game On Another Arduino

It initially looks like the sensor is making the dinosaur jump a little too early, but it doesn’t hit the cactuses and you need to it respond quickly later on in the game. It starts to look better as the game progresses.

LDR Detecting Cactuses

You may need to make a few adjustments to the servo travel limits and to the cactus detection set points in your code to get it to work correctly.

Arduino Playing The Chrome Dino Game On Another Arduino - Side

Also, position the LDR as close to the LCD as possible. These LDRs are really sensitive, I noticed a significant fluctuation in the measured values with me moving around the room or at different times of the day, so It would be a good addition to add a pot to adjust the set point at any time. This way you could get it to work in any light conditions and use it on the Arduino game or your computer without having to change the code.

Let me know in the comments if you’ve tried playing the Chrome Dino Game on an Arduino or tried getting an Arduino to play the Chrome Dino Game.

Share This Guide

An Arduino Playing The Chrome Dino Game On Another Arduino Social

Play The Chrome Dino Game On An Arduino

If you’ve been kept busy playing the Chrome Dino Game in your browser, how about loading it onto an Arduino to leave on your desk? It’s a really simple game which runs quite well on an Arduino Uno using a simple LCD keypad shield without any other hardware.

I didn’t code this game, it’s a version I found on hackster.io which seems to run the best. It’s written in AVR C code, so it looks a bit different to the generic Arduino language but you should be able to figure a lot of it out and you can still open, edit and upload it using the Arduino IDE.

Here’s a video of the Chrome Dino Game being played on an Arduino:

What You Need To Run The Chrome Dino Game

How To Load The Game Onto Your Arduino

First, start off by plugging your LCD keypad shield onto your Arduino Uno. Make sure that all of the pins are lined up correctly so that you don’t bend any of them.

Next, plug the Arduino into your computer and start up the Arduino IDE. Make sure that the correct board is selected and that you’re working on the correct com port. Then upload the below sketch. You can also change a couple of things in the sketch if you like, I’ve outlined these after the sketch.

Here’s a brief overview of the game:

  • The game speeds up the longer you play it.
  • Cactuses are initially separated by a minimum of 5 spaces and this goes down to a minimum of 3 as the game progresses.
  • Cheating by holding down the button or continuously pressing the button is prevented.
  • The current score is displayed during the game and the high score at the end.
  • The high score is not saved and is lost when power to the Arduino is removed.

Let’s have a look at the code:

//From Hackster.io
//By BRZI

#include <avr/io.h>
#define  F_CPU 16000000UL //Our CPU speed (16MHz)
#include <util/delay.h> //Libraries for delay and interrupt utilities
#include <avr/interrupt.h>
#define command 0 //explained in dispSend() function
#define write 1

uint8_t upperBuff[16] , downerBuff[16], overMsgUpper[] = "Score:  ", overMsgDowner[] = "Best:   ", scoremsg[] = "Score:" , din[] = {0x0E, 0x17, 0x1E, 0x1F, 0x18, 0x1F, 0x1A, 0x12}, cact[] = {0x04, 0x05, 0x15, 0x15, 0x16, 0x0C, 0x04, 0x04};
        //Buffers for line one and two. Message to display after lost game.                     //Score text during game. //Dinosaur and cactus bitmaps
uint8_t canup = 1, longhold = 0, distance = 6, speed = 200, isup = 0, dontprint = 0; //All of these are explained further
uint16_t aVal = 0, score = 1, bestscore = 0;
int i;

void dispInit();
void dispWrite(uint8_t bits);
void dispSend(uint8_t bits, uint8_t act);
void dispSetLine(uint8_t line);
void dispClear();
void dispHome();
void dispPrintChar(uint8_t chr[], uint8_t size);
uint16_t aRead();

int main(void)
{
  for(i = 0; i < 17; i++) downerBuff[i] = ' '; //Initialize upper and downward buffer
  for(i = 0; i < 17; i++) upperBuff[i] = ' ';
  
  dispInit(); //Initialize the display
  
  TCCR1B |= (1 << WGM12) | (1 << CS11); //Set Timer1 to compare to OCR1A and prescaler of 8
  OCR1AH = (500 >> 8); //This equals to 2000Hz or 500us timing, look for TIMER1_COMPA_vect down below
  OCR1AL = 500;
  TIMSK1 |= (1 << OCIE1A); //Enable Timer1 CompA ISR
  sei(); //Enable global interrupt

  
  ADMUX = (1 << REFS0); //Set AREF to VCC
  ADCSRA = (1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0) | (1 << ADEN); //set ADC prescaler to 128 and enable ADC (defaulted to free running mode)
  
  while (1) {   
    
    ADMUX |= (1 << MUX2) | (1 << MUX0); //Set pin from ADMUX to ADC5 (floating)
    srand(aRead()); //Use it as a random seed
    ADMUX &= ~(1 << MUX2) & ~(1 << MUX0); //Revert back to ADC0 to read the button value

    if(aRead() > 900) longhold = 0; //Reads if Up button has been released to prevent cheating. The value is so low because if you hold your fingers beneath one of the buttons the voltage would drop, this prevents the dinosaur from locking up

    for(i = 0; i < 16; i++) downerBuff[i] = downerBuff[i + 1]; //Shifts everything in downward buffer by one place to the left
     if((rand() % 100) > (rand() % 100) && !dontprint){ //This portion decides if it should put a cactus or a blank spot, dontprint is used to prevent cactus grouping
      downerBuff[15] = 0x01; //0x01 represents the cactus (we added cactus and dinosaur to CGRAM when we initialized the display)
      dontprint = 1; //This part acts both as a boolean and a counter to ensure cactus separation
     }
     else downerBuff[15] = ' ';
     char lastchar = downerBuff[3]; //We remember the whats initially added to the downward buffer before replacing it with the dinosaur
     if(!isup){ //If din should be placed down
      downerBuff[3] = 0x00; //Place it down
      dispSetLine(2);
      dispPrintChar(downerBuff, sizeof(downerBuff)); //Draw it
      downerBuff[3] = lastchar; //Place back previous thing to the buffer
      canup = 1;  //This flag is used to disable dinosaur from getting up before it was drawn down, in this case he can go up
    } else { //If din should be placed up
      upperBuff[3] = 0x00; //Place it up in upper buff
      dispSetLine(1);
      dispPrintChar(upperBuff, sizeof(upperBuff));
      dispSetLine(2);
      dispPrintChar(downerBuff, sizeof(downerBuff)); //Draw it
      canup = 0; //In this case he wont go up until rendered on line 2
    }

    if(dontprint) dontprint++;
    if(dontprint > distance) dontprint = 0; //This is the part that ensures cactus separation, it will keep the cactus 3-5 spaces apart minimally (depends on the game progress)
    
    if(isup) isup++; //This part makes sure din is on upper side for 3 loops after he was initially drawn there
    if(isup > 4){
     upperBuff[3] = ' ';
     dispSetLine(1);
     dispPrintChar(upperBuff, sizeof(upperBuff));
     isup = 0;
    }
    for(i = 0; i < sizeof(scoremsg); i++) upperBuff[i + 5] = scoremsg[i]; //This part prints the current score during the game
    uint8_t cnt = 11;
    for(i = 10000; i > 0; i /= 10){
      upperBuff[cnt] = ((score / i) % 10) + '0';
      cnt++;
      dispSetLine(1);
      dispPrintChar(upperBuff, sizeof(upperBuff));
    }

    score++; //Increment the score once on loop
    if(score > bestscore) bestscore = score; //Remember best score
    
    if(lastchar == 0x01 && !isup){ //Check if the dinosaur is downward and hit a cactus
      dispClear(); //Clear the display and buffers
      for(i = 0; i < 17; i++) downerBuff[i] = ' ';
      for(i = 0; i < 17; i++) upperBuff[i] = ' ';
      uint8_t cnt;
      
      dispSetLine(1);
      for(i = 0; i < sizeof(overMsgUpper); i++) upperBuff[i] = overMsgUpper[i]; //Display worst and best score
      cnt = sizeof(overMsgUpper) - 1;
      for(i = 10000; i > 0; i /= 10){
        upperBuff[cnt] = ((score / i) % 10) + '0';
        cnt++;
      }
      dispPrintChar(upperBuff, sizeof(upperBuff));
      
      dispSetLine(2);
      for(i = 0; i < sizeof(overMsgDowner); i++) downerBuff[i] = overMsgDowner[i];
      cnt = sizeof(overMsgDowner) - 1;
      for(i = 10000; i > 0; i /= 10){
        downerBuff[cnt] = ((bestscore / i) % 10) + '0';
        cnt++;
      }
      dispPrintChar(downerBuff, sizeof(downerBuff));
      
      while(1){ //Wait for select button to be pressed
        aVal = aRead();
        if(aVal > 635 && aVal < 645){ //After that clear all the variables
          for(i = 0; i < 17; i++) downerBuff[i] = ' ';
          dispSetLine(1);
          dispPrintChar(downerBuff, sizeof(downerBuff));
          for(i = 0; i < 17; i++) upperBuff[i] = ' ';
          dispSetLine(2);
          dispPrintChar(upperBuff, sizeof(upperBuff));
          dontprint = 0;
          isup = 0;
          score = 1;
          speed = 200;
          longhold = 0;
          distance = 6;
          canup = 1;
          break;
             }
      }
      
    }
        if(score % 5 == 0) speed -=2; //If score is divisible by 5 make game faster by -2ms
    if(speed < 120) speed = 120; //Minimal time in ms (+ ~2ms) that the loop will be halted for (limited by display refreshing, in my testing 11.8Hz was readable enough to be playable)
    if(score % 175 == 0) distance--; //Every time you score a number divisible by 175 minimal cactus distance gets smaller
    if(distance < 3) distance = 3;
    for(i = 0; i < speed; i++) _delay_ms(1); //This is the only way as the compiler expects a const number here
  }
}

void dispInit(){
  _delay_ms(50); //Just in case
  DDRD = 0b11110000; //Set these pins to output. PD4 - PD7 correspond to D4 - D7 on display, we need to configure it to run in 4 bit mode
  DDRB = 0b00000011; //PB0 is tied to RS and PB1 to EN
  dispWrite(0x30);//*This part here is explained in Hitachi HD44780 datasheet on how to initialize the display in 4bit mode
  _delay_us(4500);//*Essentially you send the reset signal 3 times, and then set it to 4 bit mode
  dispWrite(0x30);//*
  _delay_us(4500);//*
  dispWrite(0x30);//*
  _delay_us(4500);//*
  dispWrite(0x28);//*
  dispSend(0x28, command); //Send 4bit mode function set
  dispSend(0x08, command); //Turn the display off
  dispSend(0x01, command); //Clear its RAM (if MCU resets that doesn't mean the display was reset, so we clear everything)
    _delay_ms(50);
  dispSend(0x0C, command); //Turn the display on
  _delay_ms(5);
  dispSend(0x40, command); //Tell the display we want to enter a custom character to its CGRAM (on address 0x00)
  for(i=0; i<8; i++) dispSend(din[i], write);
  dispSend(0x80, command); //Transaction end
  dispSend(0x48, command); //Same thing, but for 0x01
  for(i=0; i<8; i++) dispSend(cact[i], write);
  dispSend(0x80, command);
}

void dispPrintChar(uint8_t chr[], uint8_t size){
  for(uint8_t i = 0; i < size; i++) dispSend(chr[i], write); //Self explanatory 
}

void dispSetLine(uint8_t line){
  if(line == 2) dispSend(0xC0, command); //Sets the line where 0xC0 is line 2 and 0x80 is line 1
  else dispSend(0x80, command);
}

void dispClear(){
  dispSend(0x01, command); //Self explanatory 
  _delay_ms(2); //This command takes longer for the IC to process, this delay is necessary
}

void dispHome(){ //This function isn't used in this application but its there for expandability, it places the cursor on the line 1 column 1
  dispSend(0x02, command); //Self explanatory 
  _delay_ms(2);
}

void dispSend(uint8_t bits, uint8_t act){
  if(act) PORTB |= (1 << DDB0); //Set PB0 if we are writing a character, else pull it low
  else PORTB &= ~(1<<DDB0);
  dispWrite(bits); //Send the bit then shift them 4 bit to the left to work in displays 4bit mode
  dispWrite(bits << 4);
  _delay_us(80);
}

void dispWrite(uint8_t bits){
  PORTD = bits; //This is a dirty way to write it but it's perfect for this application as it's not bulky and PORTD isn't used for anything else anyway
  PORTB |= (1<<DDB1); //Pulse the PB1 to signal the IC to read the data
  _delay_us(1);
  PORTB &= ~(1<<DDB1);
  _delay_us(1);
}

uint16_t aRead(){
  ADCSRA |= (1 << ADSC); //This signal the avr to read the ADC value
  while  (ADCSRA & (1 << ADSC)); //Wait until it's finished
  return ADCL | (ADCH << 8); //Send it back stitched together
}

ISR (TIMER1_COMPA_vect){ //Timer ISR we set up earlier
  if(!longhold){ //Return if the Up button was still held
    aVal = aRead(); //Read from ADC0
    if(aVal > 450 && aVal < 600 && canup){ //Check if Up is pressed and that din was rendered down
     isup = 1;
     longhold++;
     }
    }
}

Download The Sketch – ChromeDinoGame

Playing The Chrome Dino Game On An Arduino

Things You Can Change In The Game

There are a couple of things you can edit to customise the game without knowing AVC C code, here are some of them:

  • Line 11 – Change the score/high score screen text.
  • Line 140 – Change by how much the speed increases every score increment of 5, or change the increment.
  • Line 141 – Change the maximum speed limit. The original coder suggests nothing less than 120ms a cycle or it becomes unplayable on the LCD.
  • Line 142 – Change how often the cactus spacing gets closer together.
  • Line 143 – Change the minimum cactus distance.

The game is quite easy to play on the LCD keypad shield although the buttons are not the best for quick presses and the LCD is quite slow, so it starts suffering from ghosting and brightness issues once the cactuses start moving quickly.

Let me know if you’ve loaded this game onto your Arduino Uno and what you’ve changed on it. Enjoy playing it!

The Best Cleaning Shortcuts For 2020

Not very many people enjoy cleaning, so we’re all looking for ways to make cleaning a bit quicker and easier. Here’s a list of our favourite cleaning shortcuts for 2020 to help you get your home looking great without too much time and effort.

Slip a paper towel tube or toilet roll over the end of your vacuum hose. This allows you to squash the end of the tube to fit into all those gaps which were previously hard to reach, think window and door sliders, between the couch cushions and in the corners of cupboards and drawers. The cardboard also won’t scratch or damage your trim, walls or furniture.

place your cutlery into the container

Clean your silver jewellery and cutlery with baking soda, salt and aluminium foil. The reaction removes the silver tarnish, doesn’t damage your jewellery and doesn’t require any rubbing or brushing.

Are your glasses and cutlery coming out of the dishwasher cloudy?  Most people think that this is because they’re not using enough rinse aid or salt. If you use tablets in your dishwasher then its more likely that you’re using too much rinse aid. These tablets are typically designed to be “all in one” so they don’t require you to add rinse aid and salt to your machine as well. In fact, some machines ask you if you are using a tablet and then do not dose extra rinse aid into the water.

Dish Soap Dispensing Brush

Hang a soap dispensing dish brush in your shower. Instead of having to give your shower a big clean every week, hang a dish brush with some liquid in it in your shower and get into a habit of giving the shower a quick clean after every use. It’ll still be hot and the grime won’t have dried in place so it’ll be quicker and easier to keep clean in the long run.

If you’ve got unexpected guests coming over to your home, here’s a guide to fake a clean and tidy home in under 15 minutes – your guests won’t suspect a thing.

Cleaning Laundry Detergent Cap

If you find your laundry detergent cap getting sticky and messy from the liquid, especially when you buy larger containers, just throw the cap in with your next load. It’ll come out looking new again and requires no effort from you to clean.

Your dishwasher is not just for dishes, you can actually clean quite a few different things in the dishwasher, from kids toys to some home decor items. You can even get dinner done at the same time by cooking salmon in your dishwasher.

Ice cubes help lift furniture imprints from your carpets. Simply place a cube on the indent and let it melt. Use some paper towel to absorb the water and allow it to dry and your carpet will be as good as new again.

11 Baking Soda Hacks You Need To Try

A cup of baking soda will deodorise your closet. Simply place an open cup of baking soda into the corner of your cupboard to absorb any moisture and reduce that musty or damp smell. Also, have a look at these other baking soda hacks which you need to try.

Coffee grounds make a great eco-friendly and gentle scourer to clean your pots and pans. Use a tablespoon of spent coffee grounds to make washing your dirty pots and pans a breeze. You can also use your spent coffee grounds in the garden as a natural fertilizer.

Now that you’ve got some shortcuts lined up to keep you home clean, you’ll have more time for your next DIY project. Let us know how else you’ve saved time cleaning your home in the comments section below.

Share This Guide

The Best Cleaning Shortcuts For 2020

Connect Up To 992 Servos To An Arduino, Using I2C – Just 2 Pins

In this tutorial, I’m going to be showing you how to connect up to 992 servos to an Arduino by using these 16 channel PCA9685 PWM drivers, which are controlled over the I2C interface. Each one of these boards can drive up to 16 servos or PWM outputs and you can chain up to 62 of them together, meaning that you could drive up to 992 servos – all controlled by just two pins on your Arduino. They’re also relatively inexpensive, there are good quality ones available for around $10 online, but you can also find ones from just $2-$3 each if you’re prepared to wait a bit longer for shipping.

Here’s a video summary of the tutorial and servos in operation, read on for the step by step instructions and the code:

What You Need For This Tutorial

How To Connect & Drive Your Servos

Each board has two sets of control input pins, one on each side. You can use either set of control inputs to connect your board to your Arduino, but they’re primarily useful to chain the drivers together. Each board can be plugged into the pins on the board before it, with the first connected to your Arduino.

PCA9685 Out Of Box

Each board also has two power terminals at the top to provide a dedicated 5-6V power supply to the outputs and then the 16 outputs along the bottom. What’s also nice about these boards is that they’re already set up to accommodate the 3 pin servo plugs. So you can plug your servos directly into the board instead of needing additional wiring like you’d need if you were plugging the servo directly into your Arduino. 

Address Pins

On the top right of each board is a set of bridgeable address jumpers which allow you to bridge different combinations to create a unique address for up to 62 different boards. To change the address of a board, you just need to solder a bridge across the two address terminals. This changes the address as follows:

  • Board 0 – Address Terminals 000000 (no jumpers used) – Address 0x40
  • Board 1 – Address Terminals 000001 (solder jumper over A0) – Address 0x41
  • Board 2 – Address Terminals 000010 (solder jumper over A1) – Address 0x42
  • Board 3 – Address Terminals 000011 (solder jumpers over A1 & A0) – Address 0x43
    • And so on…

You can also use these boards to control LEDs, so you can control 992 LEDs individually and control their brightness as well. Although each channel is completely independent, each board must operate at the same PWM frequency. This means that if you’d like to use a combination of LEDs and servos, you’d likely need to split them up across two boards because servos typically operate at 50Hz and LEDs at 1kHz. Also, keep in mind that the maximum current output per pin is 25mA and there are already 220 home resistors in series with all of the PWM pins.

Have a look at this 7 segment display clock which was built using these PCA9685 servo drivers.

Connecting The Boards Together & To Your Arduino

To chain two boards together, we’ll need to add some pins to the right side of the board to plug the next board into.

Add Pin Headers To The Second Side

We’ll then bridge the first terminals on the right to change the address on the second board so that our Arduino can differentiate between the two.

Solder Address Jumpers

Changed The Address On PWM Servo Driver

Looking at the back of the board, the board accepts two supply voltages, one between 3 and 5 volts for the logic or onboard chip and the second up to 6V which is to supply the output pins. There is also a note to say that the terminals at the top have reverse polarity protection while the input on the side through the control pins does not.

Under Side Of 16 Channel PWM Servo Driver

The power supplied through the terminals is fed to the V+ control pin, meaning that you don’t need to connect every board in the chain through the terminals, unless you’re drawing a lot of current on each.

Create a Ribbon Cable To Join Boards Together

Now that we’ve added the second set of control pins and changed the address on the second board, we need to create a ribbon cable connector to join the two boards together. You only need to connect 4 pins to your Arduino and between each board, the ground, the two I2C pins and the logic supply voltage VCC. The other two pins, OE and V+ are used to enable or disable the boards and to supply voltage to the output pins. I’ve created ribbon cable to connect all six pins between the boards so that the output voltage is fed to the second board and so that I can use the enable pin in future if needed.

16 Channel PWM Servo Driver Schematic

When connecting your PWM drivers to your Arduino, make sure that you use the correct I2C pins.

Connection To Arduino

This is through analogue pins 3 and 4 on older Arduino Uno’s, through digital pins 20 and 21 on older Megas and through the dedicated SDA and SCL pins on later model Unos, Megas and Leonardos. Remember that Vcc is only to supply the logic circuits on the drivers, not the outputs. To drive the outputs it is recommended that you use a dedicated supply through the terminals. 

Servos Connected To 16 Channel PWM Drivers

Now go ahead and plug your servos into the output pins on your boards. Make sure that the plugs are put in the correct way around, with the brown wire being ground and the orange wire being the PWM signal.

Programming Your Arduino To Control The Servos

Now let’s have a look at the code and how to control each servo.

We’re going to be using the Adafruit PWM servo driver library. You can install this library easily from the Arduino IDE by going to Sketch -> Include Libraries -> Manage Libraries then searching for Adafruit PWM and clicking install.

Installing The Adafruit PWM Servo Driver Library

Once the library is installed, we can write a simple program to move each of the 6 servos on each board individually.

//Michael Klements
//The DIY Life
//3 May 2020

#include <Adafruit_PWMServoDriver.h>                             //Include the PWM Driver library

Adafruit_PWMServoDriver pwm1 = Adafruit_PWMServoDriver(0x40);    //Create an object of board 1
Adafruit_PWMServoDriver pwm2 = Adafruit_PWMServoDriver(0x41);    //Create an object of board 2 (A0 Address Jumper)

int servoMin =  150;        // This is the servos minimum pulse length count (out of 4096)
int servoMax =  600;        // This is the servos maximum pulse length count (out of 4096)
int servoFrequency = 50;    // Servo update frequency, analog servos typically run at ~50 Hz

void setup()
{
  pwm1.begin();             //Start each board
  pwm2.begin();
  pwm1.setOscillatorFrequency(27000000);    //Set the PWM oscillator frequency, used for fine calibration
  pwm2.setOscillatorFrequency(27000000);
  pwm1.setPWMFreq(servoFrequency);          //Set the servo operating frequency
  pwm2.setPWMFreq(servoFrequency);
}

void loop()
{
  for (int i=0 ; i<=5 ; i++)   //Cycle through moving 6 servos on each board
  {
    for (int pulseLength = servoMin ; pulseLength <= servoMax ; pulseLength++)    //Move each servo from servoMin to servoMax
    {
      pwm1.setPWM(i, 0, pulseLength);           //Set the current PWM pulse length on board 1, servo i
      pwm2.setPWM(i, 0, pulseLength);           //Set the current PWM pulse length on board 2, servo i
      delay(1);
    }
    delay(100);
    for (int pulseLength = servoMax ; pulseLength >= servoMin ; pulseLength--)    ////Move each servo from servoMax to servoMin
    {
      pwm1.setPWM(i, 0, pulseLength);           //Set the current PWM pulse length on board 1, servo i
      pwm2.setPWM(i, 0, pulseLength);           //Set the current PWM pulse length on board 2, servo i
      delay(1);
    }
    delay(100);
  }
  delay(500);
}

Download Sketch – PCA9685Tutorial

We start by importing the Adafruit library.

We then create a new object for each of the connected boards, remembering to change the address to suite the address jumpers we’ve used.

We then set a minimum and maximum travel limits for our servos. This is quite important so that you’re not over travelling your servos which may cause them to burn out or strip the gears. We also set the servo operating frequency. Most analogue servos run at 50hz.

In the setup function, we start each board then set the oscillator frequency and the servo frequency.

In the loop function, we’ve got a loop which cycles through the six servo numbers, numbered from 0 to 5 as per the board output numbers.

We then have a loop which drives the current servos, one on each board, from their minimum position to their maximum position with a 1ms delay between movements, which is a relatively slow servo movement.

We then wait 100 milliseconds and move the same two servos from their maximum position back down to their minimum position at the same speed.

We then wait another 100 milliseconds before moving onto the next two servos.

Once all 6 servos have been moved on each board, we wait 500 milliseconds and then start again moving the first two servos and the loop continues.

Let’s upload the sketch and have a look at the servos moving.

Two 16 Channel PWM Servos Drivers In Operation

Being able to control servos like this enables you to build more complex projects by freeing up your Arduino’s IO and reducing the processing load because these servo drivers produce their own PWM signal. These are great for building robot arms, walking robots and projects involving a lot of LEDs, such as cubes, clocks and simple games.

Let me know in the comments section below what you plan on using these drivers for.

iPhone X Ultimate Teardown – Amazing Close Up Shots

In this teardown video, I’ve taken an iPhone X apart as far as possible with a standard repair toolkit and without breaking any of the components open. I’ve also included some close-up shots of some of the more interesting components to have a look at, have a look at the stills after the video.

Did you know that you can do quite a few repairs to your iPhone yourself?  Have a look at these common iPhone repairs that you can do yourself.

Here are some of the still images of the internal components of the iPhone X from the teardown:

These ribbon cable connectors connect the various components in the iPhone together, making repairs and replacements of parts easier. Older model mobile phone’s used to have soldered connections, which required a lot of effort to replace components.

iPhone Ribbon Cable Connectors

The Taptic Engine is an electromagnetic driver which produces the vibrations you feel when your iPhone rings, for feedback when clicking on or moving items and icons and when you pressed the home button on older iPhone 7 and 8 models – the ones which had fixed home buttons which didn’t “click” when pressed when the iPhone was off.

iPhone Taptic Engine

iPhone X Teardown Taptic Engine

The dual camera assembly on the iPhone X, featuring a wide-angle, optically stabilised f/1.8 camera as seen on previous iPhone generations and a newer telephoto lens for close up and portrait shots.

iPhone X Camera Internals

FaceID was a new addition to the iPhone X, providing users with a means to securely unlock their iPhone’s without having to physically press a button or fingerprint sensor.

FaceID Sensor

The logic board is the heart of every iPhone. This is the assembly which houses the processor and control boards which drive the entire iPhone, all of the peripheral devices, such as the speakers, cameras, buttons and battery plug into this board. It’s incredible how small this board is considering what it contains and how much it can do.

iPhone X Logic Board

iPhone X teardown Logic Board

On the back of the display is a small white sticker, this is the water damage indicator which is visible through the SIM card tray. This indicator turns red permanently when it comes into contact with water, indicating possible water damage to the internal components. You can have a look at where it is in the SIM card tray and how it works in our previous article.

Water Damage Indicator

Lastly, here’s a close up of the inside portion of the lightning connector – the only port left on modern iPhones.

Lightning Port

Hope you enjoyed the teardown! Have you ever opened your iPhone up to repair it? Let us know what repairs you’ve done in the comments section below.

Share This Teardown

iPhone X Ultimate Teardown

How To Make Your Own Compost – Get Your Garden To Thrive

Compost is one of the best supplements you can give to your garden to get it to thrive. The best part is that it can easily be made at home, so it’s essentially free. It’s also a natural, chemical-free way to get your garden beds and grass looking healthier.

Choosing Or Making A Composter

For small scale home composting, there are a number of options for you to choose from, or make your own:

  • Tumbler Composter – Like This
    • A tumbler composter is definitely the best and most efficient way to produce good quality compost from your household waste in minimal time. They elevate it off of the ground, keeping it away from pests, and being able to frequently turn the compost means that the microbes are kept aerated and active. Some tumblers even have paddles or spikes built into them to assist with aerating the compost as it is turned.
  • Standard Compost Bin – Like This
    • Most home hardware stores and garden centres have a few different compost bin designs. They’re usually quite simple and great to get started. The one downside over a tumbler is that its difficult to turn, so it generally takes a lot longer than a tumbler to produce – up to 6 months.
  • DIY Compost Bin – Like This
    • This is probably going to be the least expensive way to get into composting, but it does require a bit more effort. Buy a large container or heavy-duty garbage can, one with a clip-on lid works best. Then get a larger diameter drill, around 10-15mm and drill holes in rows, roughly 20cm spaced apart all around the container/can, even along the bottom. Getting a round garbage can makes the occasional turning of the compost a bit easier as you can put it on its side and roll it around.
  • Food Waste Digester – Like This
    • This variety of composter is typically kept indoors and grinds and dehydrates the food waste rather than “composting” it. It’s still great for the garden and is certainly a good way to produce compost-like nutrients for your garden.

Choosing Or Making A Composter

Find The Right Place To Make Your Compost

You need a nice shaded place, preferably outdoors so that you don’t get any smells wafting into the house. Too much sun may dry your compost out and kill the microbes helping to make the compost.

A lot of people make the mistake of trying to keep their composter close to the kitchen or in their workshop or garage. You don’t want a pile of waste to be near any of your home’s windows or doors, much less your kitchen. The best spot for it is in the far end of your garden or in an alleyway on the side of your home. Rather keep a small bucket or bin to collect scraps in your kitchen and get into a habit of emptying it every couple of days.

If you’re looking to get your garden looking fuller and greener, have a look at these 5 Gardening Tips & Tricks That Everone Should Know.

Mix Your First Batch Together

To start your first batch, you’ll need either a bag of organic compost (like this) or compost starter (like this). This introduces the microscopic organisms into your composter to keep breaking down the scraps and waste you add in order to produce more. It is possible to start composting without these but it usually takes a lot longer. You also only need them for your first batch. In subsequent batches, you’ll leave a little in the composter from the last batch in order to kick start the process.

Add your compost or compost starter and then start adding your compost waste, making sure that you have an good ratio of brown and green waste. The best ratio is around 2/3 brown waste to 1/3 green waste, and you should never exceed a 1:1 ratio; meaning you should never have more green waste than brown waste. Brown waste is waste which has a high carbon content, such as paper, egg cartons, cardboard, straw, branches, sawdust, wood chips, coffee grounds, leaves etc.. Did you know that you can use your coffee grounds in the garden? Green waste is waste which has a high nitrogen content such as lawn clippings, fruit and vegetable scraps and other garden plant trimmings.

In order to speed up the composting process, always chop your waste up into smaller pieces. The larger the pieces going in, the longer it’s going to take to turn them into compost.

If you’re using a stationary composter or bin then you’ll need to layer or mix the waste together so that it’s evenly distributed around the vessel. If you’re using a tumbler composter then you’re job is a bit easier and you can mix it all afterwards.

It’s best to turn or aerate your compost every week or two. This is where a tumbler composter makes things a bit easier. If you’re using a bin, you’ll need to use a garden fork or shovel and gently turn it so that it doesn’t become too compact.

Your compost is done when it starts to look like soil and has an earthy smell to it.

Mix Your First Batch Together

Things You Should Never Put In Your Composter

There are a few products which should never go into a composter, they generate a large amount of bacteria and will likely cause foul odours and your compost to fail:

  • Any meat products including red meat, chicken or fish.
  • Dog or cat faeces.
  • Diseased or decaying plant material.
  • Weeds (as you may spread seeds throughout your garden through the compost)
  • Liquids.

Have you tried making your own compost? Let us know what method you used and how it went for you in the comments section below.

Make Your Own Acrylic SD Card Storage Multi-tool

In this project, I’ll be showing you how to make your own DIY SD card storage multi-tool from clear or tinted acrylic. This is a great pocket or camera bag companion to keep all of your SD and micro SD cards organised and easily accessible. It’s fully customisable, you can add or remove trays as you need or add different coloured or tinted trays to distinguish between full and empty SD cards so that you always know which is which. It also doesn’t need to be limited to three trays like the one I’ve made, you could add 5 or 8 trays if you’d like, it’ll just be a bit bulkier. You could also just go with one micro SD card tray if you prefer something more compact.

Watch the video below for the build and to see the completed product or read on for the step by step instructions.

What You Need To Make Your Own SD Card Storage Multi-tool

  • 2mm A4 Acrylic Sheet – Buy Here
  • 3mm A4 Acrylic Sheet – Buy Here 
    • You won’t need full sheets. If you’ve got some scrap acrylic lying around, you can probably use it.
  • M3 x 22mm Screws – Buy Here
  • M3 Nuts – Buy Here
  • UV GLue – Buy Here
  • Acrylic Glue Alternative – Buy Here

I used a K40 laser cutter to cut the parts. If you don’t have a laser cutter, there are loads of online cutting services available to cut your parts for you and deliver them to your door.

How To Make The Multi-tool

The layers of the multitool are all laser cut from 2mm or 3mm acrylic sheets. I designed the cutouts in Inkscape to fit both micro SD cards and full-sized SD cards..

2mm Acrylic Sheet Design

The first two cutouts are the top and bottom layers of the multitool, on the top layer I’ve included a logo to be engraved, you can replace this with your name, your business name or logo.

We’ve then got the tray bottoms. Each tray is made up of two layers which are glued together. The bottom layer is the base of the tray and is solid with no cutout sections and the top layer has the cutouts for the sd cards. The trays all have a corresponding fixed portion which is glued to the stationary housing and then a moving portion with a pullout tab.

3mm Acrylic Sheet Design

I’ve used two tray designs, one for eight micro SD cards and one for two full-sized SD cards. All of the pieces are cut out of 2mm acrylic except for the tray tops, and corresponding stationary pieces, with full-sized SD card cutouts, these are cut from 3mm acrylic.

The files can be downloaded here – Cutting Files

Acrylic Sheet Tray Designs

I’ve also included a design for one with four micro SD cards and one full-sized SD card. Remember to cut the ones with full-sized SD cards from 3mm acrylic.

I cut the pieces and engraved the logo using a K40 laser cutter.

Laser Cutting The Acrylic

Laser Cut And Engraved Components

If you don’t have a laser cutter, you could either make use of an online laser cutting service or you can trace them onto your acrylic and cut them out using a band or scroll saw. Acrylic is quite workable with hand tools, it’ll just be time-consuming.

Completed Components

Once your pieces are all cut, you’ll need to peel off the protective film.

Peel Off Acrylic Protective Film

I glued the acrylic layers together using this quick fix UV light glue because it’s clear when cured and doesn’t damage the acrylic. You can use any acrylic safe glue you’d like, preferably one which dries/cures clear so that you can still see through the layers.

Glue Components

I started by assembling the smaller pieces to the top and bottom layer to form the multitool body. It’s not critical that they’re in the correct layer order, but it does look neater when you’re done if you keep them in order as per the tray layers. You can use one of the screws as a guide to line up the pieces, just don’t get glue on it so that you can’t remove it.

Fixed Side Of Storage Multi-tool

To make the trays, you need to glue the upper cutout tray piece onto a bottom tray piece and then cure the glue. I didn’t use glue on all of the edges, just on the two ends and a bit around the middle section.

Glue Components To Make Trays

Curing The Trays

Completed Trays

I’ve used M3 x 20mm button head screws and undersized the holes on the bottom layer slightly so that I didn’t need to use the nuts. You may need different length screws if you’ve used a different combination of trays. The nuts on the end of the screws are a more durable solution if you’re going to be keeping this in your camera bag, make sure you use a drop of lock tight on the nuts so they don’t work loose.

Assemble The Storage Multi-tool

Once your trays are done, slide them into your multitool in the order you’d like them to be in and then push the second screw into the end to hold them together and act as a hinge. This screw is critical to the functioning of your multitool, you want it to be tight enough so that the trays are not loose and don’t fall out by themselves but not too tight that its difficult to open. Tighten it until you’re happy with the feel and then use a drop of lock tight on the nut or end of the screw to secure it.

Adding Hinge Screw
Your SD card storage multitool is now complete.

Completed SD Card Storage Multi-tool

Make sure that all of the glue is cured and then start adding your SD cards.

SD Card Storage Case Being Used

This also doesn’t have to be limited to SD cards. If you use different types of memory cards or you’d like a space for a flash driver or adaptor, it’s really easy to make an additional tray and expand upon your multitool’s functionality.

Acrylic SD Card Storage Case Complete

It also looks really cool in clear acrylic so that you can see all of the cards inside it.

Cards Storaed In SD Card Storage Multi-tool

Let me know in the comments section below what combination of trays you’re going to be using in your SD card storage multi-tool. Do you use more micro SD cards, SD cards or other memory cards?

Share This Guide

DIY SD Card Storage Multitool

Keeping Flowers Forever: What to do with them

Flowers are a fantastic gift that you may want to keep forever. Whether those blooms have marked a special occasion, they made you smile, or if you just really like them. We’d love to share our tips and tricks on keeping your flowers forever.

From setting your blooms up for the longest life span possible to drying and crafting with your floral arrangement, we have a lot of advice to give. 

Set Your Blooms Up For Success

Start your flowers off on the right foot by keeping them bright and beautiful for as long as possible. If you’ve purchased your flowers from a wholesaler, bought them in bulk, or just brought them home from the market, you may need to prep them before they go into a vase. 

If you’ve purchased your flowers from a florist, their designers have most likely prepped them before placing them in the vase or container.

Set Your Blooms Up For Success

Sourcing

Flowers are not just flowers. Just like food, brand name and source will hugely affect their quality. For example, a cut Rouge Baiser rose can last 10 to 14 days and are extra fragrant, whereas a regular rose, when cut, usually lasts about a week.

If you have access to a local grower, purchasing your flowers directly from them will ensure your flowers are at their freshest, giving you the longest time to enjoy your beautiful blooms. They are also experts and can lead you towards the longest-lasting varieties, what’s in season, and what will fit your project and vision.

The next best source is anyone with a direct relationship with a grower. Large, but local florists, like us at Bagoy’s Florist & Home, source our flowers directly from the growers and do offer bulk pricing. Connecting with a large, but local florist is one of the smartest ways to get fresh flowers without having to track down a grower. Smaller florists will often get their flowers from larger florists, or from a national brand like FTD or Teleflora so avoiding middlemen can be a bit tricky. If you want to find out if your local florist is sourcing from a reputable farmer, just ask them. If they know their growers, usually they like to brag about how fantastic each one is.

Picking your own wildflowers or taking trimmings from your garden makes you your own grower and is truly the best option. If you cut them early, as they bloom, your flowers will last the longest. If you cut them at full bloom, they may only last a few days.

Sourcing Flowers

Trimming

If you have purchased a bouquet, the florist will most likely trim your flowers for you. If they don’t, they probably aren’t a very good florist.

If you have purchased your flowers in bulk or cut them yourself, trimming can be simple.

Trim the stems of your flowers at a forty-five degree angle, and remove any foliage that may rest below the water, this includes leaves, thorns, or small branches.

Feed & Water

Your flowers need food and water. Changing your flower’s water often will keep their bright and beautiful blooms for the longest time. Place a little plant food in with the water each time.

If you don’t have any flower food on hand, making your own is fairly simple.

Dry Your Flowers

Drying your flowers is the easiest way of keeping your flowers forever. 

Dry Your Flowers

If you have chosen a flower that already offers a flat shape, like daisies or many wildflowers, pressing them in a book is the easiest method of drying. If you have chosen a thick flower, like a rose or hydrangea, you can hang them out of the sun for a few days or pop them in the oven at a low temperature for a day.

It is important if you have chosen to dry your flowers, to let them completely dry. If there is moisture still in your blooms, they may fall apart. Misting your blooms with hairspray or Mod Podge will ensure that the elements (humidity) don’t re-moisturize your flowers.

Craft with dried flowers

Once you’ve enjoyed your flowers for weeks and dried them, you can continue to incorporate their beauty in your life. There are so many crafts to make with your dried flowers. You can place them back in a bouquet, create a wreath or a flower crown, make potpourri, preserve them in resin, make bath bombs, fragrant satchels or potpourri, press them into a candle, doll up your thriving plant terrarium, and so much more! Our favourite place to check out crafts and ideas is Pinterest.

Craft With Dried Flowers

Resin Art

Resin art is one of the best ways to use and preserve your flowers. The options are absolutely limitless. Whether you want to make a simple paperweight for your desk, jewellery, a coaster, or accessory, pressing your dried flowers into resin will be sure to preserve them forever.

It is of high importance to be sure your flowers are fully dry when doing resin art. A bloom that still contains moisture will break down inside of the resin.

Bath Bombs

Bath Bombs are shockingly easy to make. Corn Starch, baking soda, Epsom salt, oils for your skin, and citric acid are almost all you need. Whether you want to pack your’s with glitter or dried flowers, you can be sure that your relaxing tub time is perfect for you. This is an especially fun D.I.Y. for anyone who got flowers for a special occasion. 

Bathing with your anniversary flowers will get you in the perfect mood for a date night!

Light It Up: Candles, Lanterns, & Don’t Smoke Them

Adding your dried flowers to a candle or lantern really brightens your day! It’s a fantastic beauty. 

Some people smoke dried petals, especially rose petals. While this is a popular choice, it can be a deadly one. Smoking, in general, isn’t good for you, and smoking a flower that may have been treated with pesticides can be downright dangerous. We would not recommend smoking your dried flowers.

If you are looking to burn your dried flowers, simply press them into a candle.

Herbal Pillows & Potpourri

Herbal Pillows & Potpourri

Placing your dried petals in a sachet will scent your drawers or closet. You can also place your dried petal in a bowl with other fantastically fragrant things, like cinnamon sticks, orange peels, a bit of sandalwood, or whatever you want your room to smell like.

If you want your flowers to last forever, buy good flowers, take care of them, and dry them. Crafting with dried flowers is an easy way to get the most out of your beautiful blooms.