Travis' World

News:

  • Registration is OPEN. but i do monitor every post.
    trying to prevent data scavengers, and spammers from abusing my server.
  • Forum boards can be created upon request, if you have a specific category you want to post about.
  • There have been a lot of ERRORS lately, due to me moving the website to another server. i am still getting them ironed out, please bear with me.

Useful Code

Travis Farmer · 182

0 Members and 1 Guest are viewing this topic.

Offline Travis Farmer

  • Administrator
  • Full Member
  • *****
    • Karma: +1/-0
    • Gender: Male
    • Travis' World
on: 2018-09-10, 09:40:13
Code: [Select]
/**
Returns the voltage of the raw pin based on the 3.3V rail
This allows us to ignore what VCC might be (an Arduino plugged into USB has VCC of 4.5 to 5.2V)
Battery level is connected to the RAW pin on Arduino and is fed through two resistors:
10K on the high side (R1), and 1K on the low side (R2)
*/
float get_battery_level()
{
  float operatingVoltage = analogRead(REFERENCE_3V3);

  float rawVoltage = analogRead(BATT);

  operatingVoltage = 3.30 / operatingVoltage; //The reference voltage is 3.3V

  rawVoltage = operatingVoltage * rawVoltage; //Convert the 0 to 1023 int to actual voltage on BATT pin

  rawVoltage *= 11.0; //(10k+1k)/1k - multiple BATT voltage by the voltage divider to get actual system voltage

  return(rawVoltage);
}

Network Administrator


Offline Travis Farmer

  • Administrator
  • Full Member
  • *****
    • Karma: +1/-0
    • Gender: Male
    • Travis' World
Reply #1 on: 2018-09-10, 09:41:04
Code: [Select]
void soft_reset() {
  asm volatile("jmp 0"); 
}

Network Administrator