00001 # This file is Copyright 2007, 2009 Dean Hall. 00002 # 00003 # This file is part of the Python-on-a-Chip program. 00004 # Python-on-a-Chip is free software: you can redistribute it and/or modify 00005 # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 00006 # 00007 # Python-on-a-Chip is distributed in the hope that it will be useful, 00008 # but WITHOUT ANY WARRANTY; without even the implied warranty of 00009 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00010 # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 00011 # is seen in the file COPYING up one directory from this. 00012 00013 ## @file 00014 # @brief Sample code to illustrate use of 00015 # PIC24/dsPIC33-specific Python functions 00016 # 00017 00018 # Load in the PIC24/dsPIC33 library 00019 import pic24_dspic33 as pic 00020 00021 # Demo some of the PIC hardware functions 00022 # --------------------------------------- 00023 00024 # Toggle a pin 00025 # port pin isInput isOpenDrain pullDir 00026 dio = pic.digital_io(1, 1, False, False, 0) 00027 dio.set(not dio.get()) 00028 00029 # Do some analog input 00030 ain = pic.analog_input(0) 00031 print ain.getVoltage() 00032 00033 # Do some PWM 00034 # freq isTimer2 oc ocPin 00035 pwm1 = pic.pwm(1000, True, 2, 0) 00036 pwm1.set(0.5) 00037 00038 # Now run main.py to start up ipm 00039 import main