Advertisement
learnelectronics

MOSFET or BJT with Arduino

Jun 17th, 2019
737
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.16 KB | None | 0 0
  1. /*
  2.  * ------------------------------------------
  3.  * |                                        |
  4.  * |          I need more POWER!            |
  5.  * |                                        |
  6.  * |           learnelectronics             |
  7.  * |            16 June 2019                |
  8.  * |                                        |
  9.  * |     A look at using transistors        |
  10.  * |     in your Arduino projects to        |
  11.  * |     overcome the Arduino's 40mA        |
  12.  * |     per pin current limit.             |
  13.  * |                                        |
  14.  * |     www.youtube.com/c/learnelectronics |
  15.  * |                                        |
  16.  * |     [email protected]              |
  17.  * |                                        |
  18.  * ------------------------------------------
  19.  */
  20.  
  21.  
  22. // Universal variables
  23.  
  24. int vPow = 0;
  25. int bulb = 3;
  26.  
  27.  
  28.  
  29.  
  30.  
  31. void setup() {
  32.  
  33.   Serial.begin(9600);
  34.    pinMode(bulb, OUTPUT);
  35.  
  36.  
  37. }
  38.  
  39. void loop() {
  40.   int pot = analogRead(A0);
  41.   vPow = map(pot,0,1023,0,255);
  42.     Serial.print("raw=");
  43.     Serial.println(pot);
  44.     Serial.print("vPow=");
  45.     Serial.println(vPow);
  46.    
  47.  
  48.   analogWrite(bulb,vPow);
  49.    
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement