How to change the image in the admin login page of WordPress like a pro!

We at Learn2Create recently thought of changing the logo on our admin page from the default WordPress Logo to our own. And, WE DIDN’T WANT TO USE A PLUGIN TO DO THAT!

Requirements:

  • Access to the CPanel
  • Basic knowledge about css and using broswer tools

Just like everyone I googled up “Change WordPress Logo on Admin login page” and tons of articles loaded up but, none of them were helpful. One article suggest that I insert a piece of code to override the settings or to use a plugin.

The official documentation by WordPress wasn’t clear about which file I had to edit.

Here’s how I did it, without overriding the settings or installing a plugin.

In pointers:

1. Open the wp-login.php file present in the root (public_html) of your WordPress installation.
File Path : root > wp-login.php

2. Open the external CSS file ‘login.min.css’  present in the css folder inside wp-admin folder.
File Path : root > wp-admin > css > login.min.css

3. Using Page Search feature on the browser CRTL+F search for '.png' in the CSS file. By default there will be two images - a .png and a .svg file. Remove the URL from the background style and replace it with the URL to your logo.

.login h1 a{
background-image:url(//yoursite.com/wp-content/uploads/2016/04/new_logo2.png);
background-image:none,url(//yoursite.com/wp-content/uploads/2016/04/new_logo2.png);
-webkit-background-size:200px;
background-size:200px;
background-position:center top;
background-repeat:no-repeat;
color:#444;
height:100px;
font-size:20px;
line-height:1.3em;
margin:0 auto 25px;
padding:0;
width:100%;
text-indent:-9999px;
outline:0;
display:block
}

 

4. Congratulations, you have successfully changed the image that loads up in your wordpress admin login page.

But, notice that the image still links to ‘wordpress.org’ and the alt text says ‘Powered by WordPress’. To change that, head back to the wp-login.php file and using Page Search feature (CRTL+F) search for ‘Powered by WordPress’; you’ll find two lines – the link and the alt text, change them both and you are good to go!

do_action( 'login_head' );

if ( is_multisite() ) {
 $login_header_url = network_home_url();
 $login_header_title = get_network()->site_name;
 } else {
 $login_header_url = __( 'https://yoursite.com/' );
 $login_header_title = __( 'YourSiteName' );
 }

 

NOTE :

  • If you do not have a ‘login.min.css’ file then edit the ‘login.css‘ file.
  • If the new logo that you added doesn’t fit then, set the width to 100% and change the background-size till it fits properly.

Hope this helps! 🙂

Check Out Other Beginner’s Articles on Learn2Create:

Run a program on Raspberry Pi using after closing SSH Connection
Programming an Arduino using a Raspberry Pi
A beginner’s guide to Programming
A beginner’s guide to Android Development
A beginner’s guide to Robotics

Let us know of any updates or edits on this matter in the comment section below. Learn to create with Learn2Create!

Run A Program On Raspberry Pi After Closing SSH Connection

Run A Program On Raspberry Pi After Closing SSH Connection

Are you one of those guys who prefer to use a headless Raspberry Pi connected via SSH?

Have you tried running a script on Raspberry Pi and wished you could terminate the SSH connection, shut down your PC and just go about doing your thing while the Pi keeps on running the script you asked it to?

There are multiple ways of keeping a program running in the background even after terminating the terminal process and/or the SSH connection.

The one that I particularly found apt for this situation is the ‘screen’. ‘Screen’ is not included in raspbian by default so we would have to install it on our Raspberry Pi.

Just in case you aren’t through the setup, here’s how: Setting up a Headless Raspberry Pi

Let’s start by SSH ‘ing into your Raspberry Pi:

[email protected]: ssh [email protected]

Once you have established a connection with your Raspberry Pi proceed further to,

1. Installing the ‘screen’ on your Pi:

[email protected]:~ $ sudo apt-get install screen

2. Check the number of ‘screen’ processes running by:

[email protected]:~ $ screen -list
No sockets found in /var/run/screen/S-pi.

*This means that there are no current programs running using screen. Let’s start a process!

Say you want to run a python program called hey.py that prints out ‘HEY’ every 30 seconds.

#!/usr/bin/env pythons
from time import sleep
while True:
    print('HEY!')
    sleep(30)

3. Initiate a process on the ‘screen’:

[email protected]:~ $ screen python3 hey.py &

*The ‘&‘ keeps the process running in background

4. Break/Detach from the ‘screen’ process:

Press CRTL+A and CRTL+D in succession

5. Check for the ‘screen’ processes:

[email protected]:~ $ screen -list
There is a screen on:
	1840.pts-0.raspberrypi	(15/02/18 12:13:31)	(Detached)
1 Socket in /var/run/screen/S-pi.

*This shows that one screen process is running in the background. NOTE: In 1840.pts-0.raspberrypi the 1840 is the process ID within ‘Screen’.

6. Re-enter the ‘screen’ process:

[email protected]:~ $ screen -r 1840

*If there is only one process running under screen then you don’t have to use the process ID.

You can view all the outputs in the particular ‘screen’ after re-entering it.

At this point you can exit the screen by pressing CRTL+A and CRTL+D in succession. Exit the SSH connection and also the local terminal running on your PC, the program will keep on running unless you re-enter the screen and manually exit the process.

Visit Screen on GNU.org

Check Out Other Beginner’s Articles on Learn2Create:

Guide to setting up a Raspberry Pi
Programming an Arduino using a Raspberry Pi
A beginner’s guide to Programming
A beginner’s guide to Android Development
A beginner’s guide to Robotics

Let us know of any updates or edits on this matter in the comment section below. Learn to create with Learn2Create!

How to turn on led light on raspberry pi

How to turn on led raspberry pi

This post only covers the simple step to turn ON a LED accessing the GPIO pins using the python GPIO library. To learn how to turn ON/OFF a LED using a web interface follow the link present at the bottom of the post.

How to turn on led raspberry pi

Prerequisites:-

  1. A Raspberry pi, obviously. We are using the raspberry pi 3 model B
  2. A Breadboard. What is it?
  3. A LED
  4. A 330 ohm resistor
  5. Two Male-Female jumper wires

You can buy points 2-5 from a local electric shop. It cost me $1.50.

Setup:-

  • Boot up the Raspberry pi.
  • Create a file on your raspberry pi and name it led.py (for now). If you are connected to raspberry pi via SSH then nano led.py
  • Copy the below code and paste it to the led.py file. We will be using the GPIO pin #17 since it’s common in all raspberry pis. Read the comments to know what each line does.
    import RPi.GPIO as GPIO
    #importing GPIO module from RPi library
    import time
    #to stop execution after some seconds
    GPIO.setmode(GPIO.BCM)
    #setting the naming convention to address the GPIO pins
    GPIO.setwarnings(False)
    #instructs python stop printing warning to the console
    GPIO.setup(17,GPIO.OUT)
    #this is necesary as it tells python that pin 17 is going to be used
    print "LED on" #to notify that the GPIO pin is going to output
    GPIO.output(17,GPIO.HIGH)
    #turns ON outputting in GPIO pin no.17
    time.sleep(1)
    #stop any further execution of the program for one second
    print "LED off"
    #to notify that the GPIO pin is about to stop outputting
    GPIO.output(17,GPIO.LOW)
    #turns OFF outputting in GPIO pin no.17
    
  • Connect jumper wire to GRND and #17 GPIO pin.

    Refer to image below

    How to turn on led light raspberry pi

  • Build the circuit.

    Follow the circuit diagram to complete the connection

    how to turn on led raspberry pi
    This is how the final circuit should look like with a breadboard

Running the code

  • To run this code type: sudo python led.py
  • You’ll see “LED on” printed in the console then stop after one second printing “LED off

Now that you have learned how to turn ON/OFF a LED on a raspberry pi, time for you to move on and build a custom interface to turn ON/OFF the LED.

Read more such articles on Learn2Create.

Using raspberry pi without a monitor

Setting up a raspberry pi without monitor.

Raspberry pi is a low cost, credit card sized micro-controller cum computer, though slightly slower than the modern desktop and laptops, the raspberry pi works pretty good given it’s size.

This micro-controller cum PC was released with the intention of using it for educational purposes, to introduce children to programming. The flexibility and low pricing made it an instant hit amongst tinkerers, makers, and electronics enthusiasts for projects that require more than a basic micro-controller (such as Arduino).

Raspberry pi credit card sized
Fits in one’s palms

The Raspberry pi can be used like any other standard PC by connecting it to the computer peripherals like Keyboard, Mouse and Display(Monitor/TV via HDMI).

What if you don’t have a spare display or need to use RPi in embedded projects, for such scenarios the raspbian for RPi rolls out with pre-installed SSH and VNC server. Those who are unfamiliar with these terms SSH stands for Secure SHell and VNC for Virtual Network Computing. These services need to be manually turned on and requires a monitor for the initial setup.

Before heading any further, you’ll need to:-

i) Set up raspbian on raspberry pi. Follow this article for setting up raspberry pi.
ii) Connect the raspberry pi to your home network.

Steps to set up a headless raspberry pi

1) Turning on the SSH and VNC servers

  • Login to your RPi using your username and password. The default username and password are pi and raspberry respectively.
  • Start the terminal by hitting Crtl+T
  • Type in sudo raspi-config. This will open up the RPi configuration dialog.
  • Navigate to the SSH and VNC section, hit enter select enable or disable to enable/disable the SSH and VNC server.
    NOTE: SSH and VNC are different tabs and need to be enabled separately.
  • Restart!

2) Using SSH Server

  • Login to your raspberry pi
  • Start the terminal by hitting Crtl+T
  • In the terminal type the following line ssh [email protected]
    (By default it is [email protected])
  • If this doesn’t work then, you must find out the local IP assigned by your router
    (Follow the guidelines provided by your router to get the list of connected devices)
  • Once you successfully find out your IP address then, you will be prompted to enter your password. The default password is – raspberry.
    To reset your password you will need to access your raspberry pi using a monitor and type in the following command in the terminal – passwd pi
  • Follow these steps and you will be connected to your raspberry pi using the terminal
  • Additionally, you can set up X-forwarding to allow the use of graphical applications. You can do that by adding a -Y flag in the command ssh -Y [email protected]<IP>

3) Using a VNC Server

VNC, or “Virtual Network Computing”, is a connection system that allows you to use your keyboard and mouse to interact with a graphical desktop environment on a remote server.
VNC makes managing a remote server easier for users who are not yet comfortable with working with the command line.

To connect to your Raspberry pi using VNC you will need to:-

  • Install a VNC Client a.k.a VNC Viewer of your choice. I used RealVNC – which supports multiple OS and even browsers.
    (You need to follow the procedures for the Operating System of your choice)

    raspberry pi without monitor
    RealVNC provides VNC Viewer for multiple OS and even browsers
  • On your Raspberry pi (using a terminal window or via SSH) get the private IP address of your RPi by typing in ifconfig
  • Enter your Raspberry Pi’s private IP address into VNC Viewer:
    raspberry pi without monitor
    Enter the Private IP into the field

    Click on connect, if this doesn’t work. You have either:
    i) Not enabled VNC server
    OR
    ii) VNC server is listening to another port, in such cases you will need to find out the port at which VNC server is listening

  • Authenticate the VNC Server by entering in the Username and password of your Raspberry pi. Default:piandraspberry
  • To start serving remote desktop through VNC type in the following command in your terminal or via SSH vncserver. It will print out the IP and the port details of the server.
  • Enter this information into the VNC Viewer and you are good to go…

A remote connection is very useful when you are using the Raspberry pi in an embedded project or when you don’t have a display to spare..

Learn how to setup a Raspberry pi for the first time – Setting up a Raspberry pi.

Use the comment section below to let us know your suggestions and/or any queries regarding the topic – Using a raspberry pi without monitor.

Setting up a Raspberry pi

How to setup a raspberry pi.

Raspberry Pi is a small, $35 computer that fits in the palm of your hand. It can run a array of low-powered operating system. The Raspberry pi can do all that your Desktop could 5 years down the line. It was launched by Raspberry pi foundation; aimed to teach programming to children all over the world. The RPi has 40 GPIO pins, it is a perfect blend of Micro-controller and a micro-computer. These things made it an instant hit amongst creators, educators, tinkerers and electronics and tech enthusiasts.

There are different models and versions of Raspberry Pi each built specifically for some purpose. The one that we are using is Raspberry Pi 3 Model B, which has a HDMI port, four USB ports, one ethernet port, WI-FI and Bluetooth.

Raspbian the official Operating system of Raspberry Pi. This is the recommended system for beginners and we stick to it for this tutorial.

    What will you be needing?

  • A Raspberry pi 3
  • A Display – Preferably with HDMI port else you would need to buy a converter
    (HDMI to VGA/HDMI to DVI)
  • A USB Keyboard and Mouse
  • A Minimum 8GB SD Card and a Card reader – I recommend buying a minimum 16GB one
  • A Power Supply – Basically a charger. 5v 2.5amps is what Raspberry pi’s official Doc suggests.
    We are using a 5v 2.4amps one

    The setup

  • First you will need to get hold of NOOBS. Download link
  • NOOBS stands for New Out Of Box. NOOBS is a installer that handles the installation part for you.
    It has a few OS Stacks included – We will go with Raspbian
  • Format the SD card
  • Once done, extract the ZIP content into your SD Card. All the necessary files will be transferred
  • When this process finishes, safely eject the SD card and insert into the Raspberry pi

    Setting up the Raspberry Pi

  • After Inserting the SD Card connect the USB keyboard and Mouse, and Ethernet Cable (optional)
  • Now connect the power supply (a micro USB charger)
  • Your Raspberry pi will boot and show you a list of operating system you can select. Select Raspbian from the option and click on install
  • Now sit back and relax as Raspbian installs itself
  • Once the installation process is done the Configuration menu for Raspbian will load up.
  • Here you can change the setting to match your locale, keyboard, enable SSH or VNC and lot other stuff.
    But you can always do that later by typing in sudo raspi-configin your terminal
  • Once you are done, you can use the Tab key on the keyboard to navigate to the Finish
  • You will be prompted for the username and password. The Default: pi&raspberry
  • You are done installing Rapbian…

To learn how to set up SSH & VNC, and to use raspberry pi without monitor (headless) check out this post – Using Raspberry pi without Monitor.

Use the comment section below to let us know your suggestions and/or any queries regarding the topic.

Beginner Robotics: The Avoider

The most crucial part of any mobile robot is the ability to avoid obstacles. What good is a robot that just runs into everything? Thankfully, object avoidance is an easy goal to achieve. With just a few parts and less than 100 lines of code, anyone can build a basic object avoiding robot!

The avoider

The Parts

All the robotics parts (Ignore how it is wired up in this picture!)

1 x DFRobot Romeo V1.3 All-In-One Microcontroller

2 x HC-SR04 Ultrasonic Object Detectors

1 x 2WD Mini Robot Frame

1 x 9V To Barrel Jack Connector

Cardboard

Electrical Tape

Mounting The Electronics

Making the cardboard sensor mount and attaching all the electronics

You’ll need to assemble the frame and figure out a way to mount the board, sensors, and battery. I used cardboard and electrical tape… So unless you’re going for a professional appearance, don’t worry about how it’s put together. However you want to do it is perfectly fine. It doesn’t have to be perfect! We’re just having fun, anyways!

[vc_row][vc_column][td_block_ad_box spot_id=”custom_ad_4″][/vc_column][/vc_row]

This is what it looked like once I attached everything

I used a small cardboard box that one of the sensors came in to raise the Romeo board above the wheels, then just electrical taped it to the frame. After that, I made a sensor mount using some taped together pieces of cardboard. The HC-SR04 sensors were also mounted with electrical tape, and I angled them slightly outwards to have more directional sensing. I ended up removing the rear swivel wheel and just letting the rear end slide around. The swivel wheel didn’t swivel very well, so it would get stuck facing one direction and make the robot turn unnecessarily.

 

Connecting Everything Together

Connection diagram

I wired the left sensor’s trigger pin to digital pin 2 on the Romeo, and the echo pin to digital pin 3. The right sensor’s trigger pin goes to digital pin 8, and the echo pin goes to digital pin 9. The Vcc wires coming from the sensors need to be spliced together into one wire and then that wire goes to 5v on the board. The Gnd wires from the sensors also need to be spliced together into one wire that connects to Gnd on the board. The motors just need to be hooked up to the green motor terminals on the Romeo. Left motor to M2 and right motor to M1.

Once, the robot has been assembled, the code can be uploaded and you can test it out!

[vc_row][vc_column][td_block_ad_box spot_id=”custom_ad_2″][/vc_column][/vc_row][vc_row][vc_column][td_block_ad_box spot_id=”custom_ad_3″][/vc_column][/vc_row]

Uploading The Code

Uploading code to the board is easy!

1. Download and install the Arduino IDE on your computer.

2. Plug in the board to the computer.

3. Select “Arduino Uno” from the Tools -> Board menu, if you are using the DFRobot Romeo board I recommended.

4. Copy and paste the code from this page into the IDE.

5. Click the upload button and you’re finished!

Here’s the code:

int trigPinLeft = 2;   
int echoPinLeft = 3;   
long durationLeft, cmLeft, inchesLeft;
int trigPinRight = 8;   
int echoPinRight = 9;   
long durationRight, cmRight, inchesRight;
void setup() {
 pinMode(trigPinLeft, OUTPUT);
 pinMode(echoPinLeft, INPUT);
 pinMode(trigPinRight, OUTPUT);
 pinMode(echoPinRight, INPUT);
}
void loop()
{
 digitalWrite(trigPinLeft, LOW);
 delayMicroseconds(5);
 digitalWrite(trigPinLeft, HIGH);
 delayMicroseconds(10);
 digitalWrite(trigPinLeft, LOW);
 pinMode(echoPinLeft, INPUT);
 durationLeft = pulseIn(echoPinLeft, HIGH);
 cmLeft = (durationLeft/2) / 29.1;
 inchesLeft = (durationLeft/2) / 74;
 delay(100);
 digitalWrite(trigPinRight, LOW);
 delayMicroseconds(5);
 digitalWrite(trigPinRight, HIGH);
 delayMicroseconds(10);
 digitalWrite(trigPinRight, LOW);
 pinMode(echoPinRight, INPUT);
 durationRight = pulseIn(echoPinRight, HIGH);
 cmRight = (durationRight/2) / 29.1;
 inchesRight = (durationRight/2) / 74;
 delay(100);
 if(inchesLeft<=10&&inchesRight<=10){
   analogWrite(6,127);
   analogWrite(5,127);
   digitalWrite(4,HIGH);
   digitalWrite(7,LOW);
   delay(1000);
 }
 if(inchesLeft>10&&inchesRight>10){
   analogWrite(6,127);
   analogWrite(5,127);
   digitalWrite(4,HIGH);
   digitalWrite(7,HIGH);
 }
 if(inchesLeft<=10&&inchesRight>10){
   analogWrite(6,127);
   analogWrite(5,127);
   digitalWrite(4,LOW);
   digitalWrite(7,HIGH);
 }
 if(inchesLeft>10&&inchesRight<=10){
   analogWrite(6,127);
   analogWrite(5,127);
   digitalWrite(4,HIGH);
   digitalWrite(7,LOW);
 }
}

Robots are easy so get the making started!