Difference between revisions of "Arduino Nano: PPT VOX"

From OnnoWiki
Jump to navigation Jump to search
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
==Analog In==
 +
 
  /*
 
  /*
 
     Detect A0
 
     Detect A0
     Switch PTT D3
+
     Switch PTT D4
 
  */
 
  */
  int State=LOW;
+
  int State;
int inPin=A0;
+
  int outPin=4;
  int outPin=3;  
 
 
   
 
   
 
  // the setup function runs once when you press reset or power the board
 
  // the setup function runs once when you press reset or power the board
 
  void setup() {
 
  void setup() {
   // initialize digital pin 3 as an output.
+
   // initialize digital pin 4 as an output.
 +
  pinMode(outPin, OUTPUT);
 
   Serial.begin(9600);
 
   Serial.begin(9600);
 
  }
 
  }
Line 15: Line 17:
 
  // the loop function runs over and over again forever
 
  // the loop function runs over and over again forever
 
  void loop() {
 
  void loop() {
   State=analogRead(inPin);
+
   State=(analogRead(A0)+analogRead(A0)+analogRead(A0)+analogRead(A0))/4;
   Serial.print(State);
+
   // Serial.print(State);
   Serial.print("\n");
+
   // Serial.print("\n");
   if( State>30) digitalWrite(outPin, HIGH);
+
   if( State<1000) digitalWrite(outPin, HIGH);
 
   else digitalWrite(outPin, LOW);
 
   else digitalWrite(outPin, LOW);
 
   delay(100);
 
   delay(100);
 
  }
 
  }
  
 
+
==Digital In==
 
 
  
 
  /*
 
  /*
 
   Rig PTT VOX
 
   Rig PTT VOX
 
   Detect D4 dari Audio
 
   Detect D4 dari Audio
   Output D3 ke Switch
+
   Output D5 ke Switch
 
   
 
   
   modified 2021 Dec 3
+
   modified 2022 June 22
 
   by Onno W. Purbo
 
   by Onno W. Purbo
  */
+
*/
 
   
 
   
 
  boolean State=LOW;
 
  boolean State=LOW;
  boolean inPin=4;
+
  int inPin=4;
  boolean outPin=3;  
+
  int outPin=5;  
 
   
 
   
 
  // the setup function runs once when you press reset or power the board
 
  // the setup function runs once when you press reset or power the board
 
  void setup() {
 
  void setup() {
   // initialize digital pin 3 as an output.
+
   // initialize digital pin 5 as an output.
 
   pinMode(outPin, OUTPUT);
 
   pinMode(outPin, OUTPUT);
 
   pinMode(inPin, INPUT);
 
   pinMode(inPin, INPUT);
Line 52: Line 53:
 
   delay(10);
 
   delay(10);
 
  }
 
  }
 
 
  
 
==Alternatif Lain==
 
==Alternatif Lain==

Latest revision as of 10:49, 22 June 2022

Analog In

/*
    Detect A0
    Switch PTT D4
*/
int State;
int outPin=4;

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin 4 as an output.
  pinMode(outPin, OUTPUT);
  Serial.begin(9600);
}

// the loop function runs over and over again forever
void loop() {
  State=(analogRead(A0)+analogRead(A0)+analogRead(A0)+analogRead(A0))/4;
  // Serial.print(State);
  // Serial.print("\n");
  if( State<1000) digitalWrite(outPin, HIGH);
  else digitalWrite(outPin, LOW);
  delay(100);
}

Digital In

/*
  Rig PTT VOX
  Detect D4 dari Audio
  Output D5 ke Switch

  modified 2022 June 22
  by Onno W. Purbo
*/

boolean State=LOW;
int inPin=4;
int outPin=5; 

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin 5 as an output.
  pinMode(outPin, OUTPUT);
  pinMode(inPin, INPUT);
}

// the loop function runs over and over again forever
void loop() {
  State=digitalRead(inPin);
  digitalWrite(outPin, !State);
  delay(10);
}

Alternatif Lain

/*
  Rig PTT VOX
  Detect D4 dari Audio
  Output D3 ke Switch

  modified 2021 Dec 3
  by Onno W. Purbo
 */

int State=LOW;
int inPin=4;
int outPin=3; 

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin 3 as an output.
  pinMode(outPin, OUTPUT);
  pinMode(inPin, INPUT);
}

// the loop function runs over and over again forever
void loop() {
  State=digitalRead(inPin);
  if( State==1 )
     digitalWrite(outPin, LOW );
  else
     digitalWrite(outPin, HIGH );
  delay(10);
}