Last active
August 29, 2015 14:07
-
-
Save avtehnik/5c021f6b4ea115d95c95 to your computer and use it in GitHub Desktop.
math of acs712
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://www.mpja.com/download/ACS712.pdf | |
<div>vcc <input id="vcc" value="5" /></div> | |
<div>vout <input id="vout" value="4.5" /></div> | |
<div>result <input id="va"/></div> | |
<script> | |
var vcc = document.id('vcc'); | |
var vout = document.id('vout'); | |
var vat = document.id('va'); | |
function acs712(vcc, vout, step){ | |
if(!step){ | |
step = 6.66666666667; | |
} | |
var result =((vout - (vcc/2))/ step)*100; | |
return result;// Math.round(result); | |
} | |
vout.addEvent('keyup',function(){ | |
vat.value = acs712(parseFloat(vcc.value) ,parseFloat(vout.value) ) | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment