mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-09-12 09:36:59 +00:00
40 lines
1.0 KiB
Python
40 lines
1.0 KiB
Python
# -*- coding:utf-8 -*-
|
|
'''!
|
|
@file output_square.py
|
|
@brief Use DAC to output square wave.
|
|
@copyright Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
|
|
@license The MIT License (MIT)
|
|
@author [tangjie](jie.tang@dfrobot.com)
|
|
@version V1.0
|
|
@date 2022-03-07
|
|
@url https://github.com/DFRobot/DFRobot_GP8403
|
|
'''
|
|
from __future__ import print_function
|
|
import sys
|
|
import os
|
|
import time
|
|
|
|
sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
|
|
from DFRobot_GP8403 import *
|
|
|
|
DAC = DFRobot_GP8403(0x58)
|
|
while DAC.begin() != 0:
|
|
print("init error")
|
|
time.sleep(1)
|
|
print("init succeed")
|
|
|
|
#Set output range
|
|
DAC.set_DAC_outrange(OUTPUT_RANGE_5V)
|
|
while True:
|
|
'''!
|
|
@brief Output square wave from channel 0
|
|
@param amp Set square wave amplitude Vp
|
|
@param freq Set square wave frequency f
|
|
@param offset Set square wave DC offset Voffset
|
|
@param dutyCycle Set square wave duty cycle
|
|
@param channel Channel select
|
|
'''
|
|
DAC.output_square(2500, 10, 2500, 50, 0)
|
|
|
|
|