EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / arduino uno

arduino uno

|

Microcontroller › Arduino › arduino uno

  • This topic has 1 reply, 2 voices, and was last updated 9 years, 7 months ago by GANEEV SINGH.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • January 21, 2016 at 7:52 am #4230
    Harsha
    Participant
    I have obtained a PWM sampling a generated sine wave for positive half cycle. I need a code for this program to obtain the same values of PWM for negative half cycle too… Plss help me asap….
     
    #include<PWM.h>
    int32_t frequency =100000;
    void setup() 
    {
    InitTimersSafe();
    bool success = SetPinFrequencySafe(9, frequency);
    if(success) {
      pinMode(13, OUTPUT);
      digitalWrite(13,HIGH);
    }
    }
     
    void loop() {
    int sensorValue= analogRead(A0);
    pwmWrite(9, sensorValue /4);
    delay(30);
     
    }
    September 29, 2016 at 5:52 am #14174
    GANEEV SINGH
    Participant

    Hi Harsha

    There are two ways to achieve what you're looking for; first is by using two PWM pins, one with sine-wave output and another with GND for the first half cycle and for the second half just interchnage these pin's outputs i.e. now second pin outputs sine-wave and first becomes GND.

    Second method: Try adding a DPDT relay and make connections like we do it for turning a DC motor in both directions (that cross connection, if you're getting). Now turn on the relay whenever you want to interchange the outputs.

    Good luck

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • Smart Buoy project May 15, 2026
  • Need Guidance to reduce noise in 3-stage Transimpedance amplifier May 15, 2026
  • Wall Radiator Heating: Efficiency and Placement Questions May 15, 2026
  • Parasitic Draw Question May 15, 2026
  • Phone Charger 5v to 12v May 14, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise