Other Arduino Codes and Videos by Robojax

DFRobot Power Shield Complete Guide

دروس آردوینو به فارسی

DFRobot Power Shield for Arduino UNO

This video shows you how to use DFRobot Power Shield for Arduino UNO

Basic Code to control output power of DFRobot Power Shield


 /*
 * Arduin code to control DFRobot Power shield
 * Using this code you can turn ON or turn OFF output power on DFRobot Power shield
 * 
 * Written by Ahmad Shamshiri for Robojax.com on Sep 01, 2018 at 11:07 in Ajax, Ontario, Canada
 * Watch video instruction for this code:
 * 
 * This code has been download from Robojax.com
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.
 * 
 */

const float vFactor = 5.0; //  (30000+7500)/7500 = 5
void setup() {

  pinMode(13,OUTPUT);// pin to control power Chip On or OFF
  digitalWrite(13, LOW);// initially turn it ON
  Serial.begin(9600);

}

void loop() {
  delay(4000);
  digitalWrite(13, LOW);// turn the output power ON
    Serial.println("Power ON");
  delay(3000);// off for 3 seconds
  digitalWrite(13, HIGH);//turn it OFF
    Serial.println("Power OFF");
  
 
}



   

Code for DFRobot Power Shield to use Voltage Sensing

This code displays the output voltage at serial monitor. See video for complete instruction.


 /*
 * Arduin code to control DF Robot Power shield
 * Using this code you can turn ON or turn OFF output power of the shield
 * and also voltage is sensed at A0 pin and displayed in serial monitor
 * 
 * Written by Ahmad Shamshiri for Robojax.com on Sep 01, 2018 at 11:07 in Ajax, Ontario, Canada
 * Watch video instruction for this code:https://youtu.be/WUeLbif-6YQ
 * 
 * This code has been download from Robojax.com
 * Get Arduino Code and watch videos at Robojax.com
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.
 * 
 */

const float vFactor = 5.0; //  (30000+7500)/7500 = 5 // see watch video for full details
void setup() {

  pinMode(13,OUTPUT);// pin to control power Chip On or OFF
  digitalWrite(13, LOW);// initially turn it ON
  Serial.begin(9600);

}

void loop() {
   digitalWrite(13,LOW);// turn ON the power
   int voltageRaw = analogRead(A0); // read A0 voltage

   float voltage = voltageRaw *(5.0/1023.0) * vFactor; // convert RAW value to actual voltage
   Serial.print("Voltage: ");
   Serial.print(voltage, 3);
   Serial.println("V");
   delay(300);
   if(voltage > 11.5)
   {
     digitalWrite(13,HIGH);// turn OFF the power
     Serial.println("Voltage limit reached ");
     delay(5000);
   }else{
     digitalWrite(13,LOW);// turn ON the power
   }
   
   delay(500);
   Serial.println("=======");
}

   

Code for DFRobot Power Shield to use LCD1602 as Voltmeter

This code displays the output voltage on LCD1602 display. See video for complete instruction.

Please download the LCD1602 Library in order to use this code


 /*
 * Arduin code to control DF Robot Power shield
 * Using this code you can turn ON or turn OFF output power
 * and display output voltage on LCD1602 as Voltmeter
 * 
 * Written by Ahmad Shamshiri for Robojax.com on Sep 01, 2018 at 11:07 in Ajax, Ontario, Canada
 * Watch video instruction for this code:https://youtu.be/WUeLbif-6YQ
 * 
 * This code has been download from Robojax.com
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.
 * 
 */

const float vFactor = 5.0; //  (30000+7500)/7500 = 5

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {

  pinMode(13,OUTPUT);// pin to control power Chip On or OFF
  digitalWrite(13, LOW);// initially turn it ON
  Serial.begin(9600);


  // initialize the LCD, 
  lcd.begin();
  // Turn on the blacklight and print a message.
  lcd.backlight();
  lcd.clear();
   lcd.setCursor (0,0); //
   lcd.print("Robojax DF Robot"); 
   lcd.setCursor (0,1); //   
 
}

void loop() {
   digitalWrite(13,LOW);// turn ON the power
   int voltageRaw = analogRead(A0); // read A0 voltage

   float voltage = voltageRaw *(5.0/1023.0) * vFactor; // convert RAW value to actual voltage
  lcd.clear();// clearn previous values from screen
  lcd.setCursor (0,0); //character zero, line 1
  lcd.print("Robojax V meter"); // print text  
  
  lcd.setCursor (0,1); //character zero, line 1
  lcd.print("Voltage:"); // print text  
  lcd.setCursor (9,1); //character 9, line 1
  lcd.print(voltage); // print voltage 
  lcd.setCursor (14,1); //character 14, line 1
  lcd.print("V"); // print V
    
  delay(500);    
}

   

If you found this tutorial helpful, please support me so I can continue creating content like this. support me via PayPal